feat(tui): migrate core surfaces to V2 themes (#37145)
This commit is contained in:
parent
a5b28c2af2
commit
5fcef6773c
37 changed files with 1389 additions and 815 deletions
41
packages/tui/src/devtools/index.ts
Normal file
41
packages/tui/src/devtools/index.ts
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
export * as DevTools from "."
|
||||
|
||||
import { createSignal } from "solid-js"
|
||||
|
||||
export type Value = string | number | boolean | null
|
||||
|
||||
export type Group = Readonly<{
|
||||
id: string
|
||||
title: string
|
||||
entries: readonly Readonly<{ key: string; value: Value }>[]
|
||||
}>
|
||||
|
||||
const [groups, setGroups] = createSignal<readonly Group[]>([])
|
||||
|
||||
export function register(input: { id: string; title: string }) {
|
||||
setGroups((groups) => {
|
||||
if (groups.some((group) => group.id === input.id)) {
|
||||
return groups.map((group) => (group.id === input.id ? { ...group, title: input.title } : group))
|
||||
}
|
||||
return [...groups, { ...input, entries: [] }]
|
||||
})
|
||||
|
||||
return {
|
||||
set(key: string, value: Value) {
|
||||
setGroups((groups) =>
|
||||
groups.map((group) => {
|
||||
if (group.id !== input.id) return group
|
||||
if (group.entries.some((entry) => entry.key === key)) {
|
||||
return {
|
||||
...group,
|
||||
entries: group.entries.map((entry) => (entry.key === key ? { key, value } : entry)),
|
||||
}
|
||||
}
|
||||
return { ...group, entries: [...group.entries, { key, value }] }
|
||||
}),
|
||||
)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
export const data = groups
|
||||
Loading…
Add table
Add a link
Reference in a new issue