mirror of
https://github.com/misode/misode.github.io.git
synced 2026-04-23 15:17:09 +00:00
Add nodes with render and transform
This commit is contained in:
17
src/nodes/EnumNode.ts
Normal file
17
src/nodes/EnumNode.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { AbstractNode, NodeMods } from './AbstractNode'
|
||||
|
||||
export class EnumNode extends AbstractNode<string> {
|
||||
private options: string[]
|
||||
|
||||
constructor(options: string[], mods?: NodeMods<string>) {
|
||||
super(mods)
|
||||
this.options = options
|
||||
}
|
||||
|
||||
render (field: string, value: string) {
|
||||
return `<span>${field}</span>
|
||||
<select value="${value}">
|
||||
${this.options.map(o => `<option>${o}</option>`)}
|
||||
</select>`
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user