import {
FullRenderingModule,
H1,
HBox,
Link,
PrimaryBodyText,
RemoteSvgIcon,
Spacer,
SvgIcon,
createDomModule,
getColor,
getSize
} from '../lib'
import { TestLayout } from './layout'
import { generateRandomColor } from './utils/color'
class IconBug extends SvgIcon {
constructor() {
super(``)
}
}
class IconCalculator extends SvgIcon {
constructor() {
super(``)
}
}
class IconCalendar extends SvgIcon {
constructor() {
super(``)
}
}
class IconController extends SvgIcon {
constructor() {
super(``)
}
}
class Page extends FullRenderingModule {
private color = getColor().text
private size = getSize().text
constructor() {
super()
this.render()
}
protected buildContent(): void {
this.addChild(
new H1('图标'),
new Spacer(20),
new PrimaryBodyText('SVG 图标'),
new Spacer(10),
createDomModule({
style: {
color: this.color,
fontSize: `${this.size}px`
},
children: [
new HBox({
gap: 16,
children: [
new IconBug(),
new IconCalculator(),
new IconCalendar(),
new IconController()
]
})
]
}),
new Spacer(20),
new PrimaryBodyText('远程 SVG 图标'),
new Spacer(10),
createDomModule({
style: {
color: this.color,
fontSize: `${this.size}px`
},
children: [
new HBox({
gap: 16,
children: [
new RemoteSvgIcon('/wok-ui/icons/alarm.svg'),
new RemoteSvgIcon('/wok-ui/icons/android.svg'),
new RemoteSvgIcon('/wok-ui/icons/apple.svg'),
new RemoteSvgIcon('/wok-ui/icons/chrome.svg')
]
})
]
}),
new Spacer(20),
new HBox({
gap: 16,
children: [
new Link({
content: '随机改变图标大小和颜色',
onClick: () => {
this.size = 10 + Math.floor(60 * Math.random())
this.color = generateRandomColor()
this.render()
}
}),
new Link({
content: '恢复默认',
onClick: () => {
this.size = getSize().text
this.color = getColor().text
this.render()
}
})
]
})
)
}
}
export function iconTest() {
return new TestLayout(new Page())
}