Skip to content

Commit

Permalink
wip: save button
Browse files Browse the repository at this point in the history
  • Loading branch information
kt3k committed Mar 28, 2020
1 parent 01de169 commit e406912
Showing 1 changed file with 25 additions and 28 deletions.
53 changes: 25 additions & 28 deletions src/script.ts
Expand Up @@ -21,7 +21,7 @@ import './app'
import './preview-modal'

@component('main-canvas')
@sub('a', 'b', 'down', 'up', 'font', 'text')
@sub('a', 'b', 'down', 'up', 'font', 'text', 'save')
export class MainCanvas {
width = 0
height = 0
Expand Down Expand Up @@ -51,29 +51,16 @@ export class MainCanvas {
this.text.shadowColor = this.colors[1].alpha(1).toString()
}

randomColor(): object {
return Color()
.hue(dice(360))
.saturationl(dice(100))
.lightness(dice(100))
.alpha(0.35)
}

baseColors() {
return [
Color()
.hue(dice(360))
.saturationl(dice(100))
.lightness(dice(100))
.alpha(0.35),
Color()
.hue(dice(360))
.saturationl(dice(100))
.lightness(dice(100))
.alpha(0.35),
Color()
.hue(dice(360))
.saturationl(dice(100))
.lightness(dice(100))
.alpha(0.35),
Color()
.hue(dice(360))
.saturationl(dice(100))
.lightness(dice(100))
.alpha(0.35)
]
return [...Array(4)].map(() => this.randomColor())
}

__mount__() {
Expand Down Expand Up @@ -188,16 +175,21 @@ export class MainCanvas {
}

@on('b')
@pub('preview-modal')
async b(): void {
const work = createWork(this.result, this.text)
const r = new WorkRepository()
await r.save(work)
this.wave.eject()
this.result.clear()
this.resetColors()
return work
}

@on('save')
@pub('preview-modal')
async save(): void {
const work = createWork(this.result, this.text)
const r = new WorkRepository()
await r.save(work)
return work
}
}

const KEY_TEXT = 'tententen-current-text'
Expand All @@ -223,11 +215,12 @@ const KEY_TEXT = 'tententen-current-text'
`)
@innerHTML(`
<input class="text-input" />
<button class="font-btn">Font</button>
<button class="font-btn">馃攣FONT</button>
<button class="up-btn">猬嗭笍</button>
<button class="down-btn">猬囷笍</button>
<button class="a-btn">A</button>
<button class="b-btn">B</button>
<button class="save-btn">SAVE</button>
`)
export class Controls {
@wired('.text-input')
Expand Down Expand Up @@ -265,4 +258,8 @@ export class Controls {
@on.click.at('.font-btn')
@pub('font')
font() {}

@on.click.at('.save-btn')
@pub('save')
save() {}
}

0 comments on commit e406912

Please sign in to comment.