-
Notifications
You must be signed in to change notification settings - Fork 309
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
204 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { colors, Dark, setCssVar } from "quasar"; | ||
import { EditorFontType, ThemeColorType, ThemeConf } from "@/type/preload"; | ||
|
||
/** テーマの設定をCSSへ反映する */ | ||
export function themeToCss(theme: ThemeConf) { | ||
for (const key in theme.colors) { | ||
const color = theme.colors[key as ThemeColorType]; | ||
const { r, g, b } = colors.hexToRgb(color); | ||
document.documentElement.style.setProperty(`--color-${key}`, color); | ||
document.documentElement.style.setProperty( | ||
`--color-${key}-rgb`, | ||
`${r}, ${g}, ${b}`, | ||
); | ||
} | ||
const mixColors: ThemeColorType[][] = [ | ||
["primary", "background"], | ||
["warning", "background"], | ||
]; | ||
for (const [color1, color2] of mixColors) { | ||
const color1Rgb = colors.hexToRgb(theme.colors[color1]); | ||
const color2Rgb = colors.hexToRgb(theme.colors[color2]); | ||
const r = Math.trunc((color1Rgb.r + color2Rgb.r) / 2); | ||
const g = Math.trunc((color1Rgb.g + color2Rgb.g) / 2); | ||
const b = Math.trunc((color1Rgb.b + color2Rgb.b) / 2); | ||
const propertyName = `--color-mix-${color1}-${color2}-rgb`; | ||
const cssColor = `${r}, ${g}, ${b}`; | ||
document.documentElement.style.setProperty(propertyName, cssColor); | ||
} | ||
Dark.set(theme.isDark); | ||
setCssVar("primary", theme.colors["primary"]); | ||
setCssVar("warning", theme.colors["warning"]); | ||
|
||
document.documentElement.setAttribute( | ||
"is-dark-theme", | ||
theme.isDark ? "true" : "false", | ||
); | ||
} | ||
|
||
/** フォントを設定する */ | ||
export function setFont(font: EditorFontType) { | ||
document.body.setAttribute("data-editor-font", font); | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { State } from "@/store/type"; | ||
import { AudioKey } from "@/type/preload"; | ||
|
||
function generateIncrementalUuid(index: number) { | ||
return `00000000-0000-0000-0000-${index.toString().padStart(12, "0")}`; | ||
} | ||
|
||
/** Stateのランダムな部分を正規化する便利関数。テスト用。 */ | ||
export function geneareNormalizedRandomState(state: State) { | ||
// これだと入れ替えたときとかにテストできない | ||
// ので、やっぱりrandomUuidを使う側をmockにしたい | ||
// globalにステートを作って、reset関数を1個まとめてあげる形がまるそう | ||
// どうやって1箇所に集めるかは課題 | ||
// フォルダ名storybookに戻しても良さそう | ||
|
||
// AudioKey | ||
const oldAudioKeys = state.audioKeys; | ||
const newAudioKeys = oldAudioKeys.map((_, index) => | ||
AudioKey(generateIncrementalUuid(index)), | ||
); | ||
state.audioItems = Object.fromEntries( | ||
oldAudioKeys.map((oldKey, index) => [ | ||
newAudioKeys[index], | ||
state.audioItems[oldKey], | ||
]), | ||
); | ||
state.audioKeys = newAudioKeys; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.