0.2.2 • Published 10 months ago
@apad/setting-panel v0.2.2
@apad/setting-panel
out-of-the-box feature and ts hint support. design with signal pattern(like mobx), provide user interface and easy manage settings.
easy to use
config.ts
import { initSetting, config } from '@apad/setting-panel'
type FontSizeType = 'small' | 'middle' | 'big'
export const { configStore, openSettingPanel } = initSetting({
settings: {
bg: '#6cf',
isDark: false,
// support ts type check
type: 'style-a' as 'style-a' | 'style-b',
// arr type
arr: ['a', 'b', 'c'],
// complex config. add description, label
lineHeight: {
label: 'line height',
desc: 'set text line height',
defaultValue: 1,
},
// group select support
fontSize: config<FontSizeType>({
type: 'group',
group: [
'middle',
'small',
// complex config
{
value: 'big',
label: 'BIG FONT!',
desc: 'BIG BIG BIG',
},
],
defaultValue: 'middle',
}),
},
})
App.tsx
import { configStore, openSettingPanel } from './config'
// make component auto update when configStore change
import { observer } from '@apad/setting-panel/react'
export default observer(() => {
return (
<div
style={{ background: configStore.bg }}
onClick={() => openSettingPanel()}
>
type: {configStore.type}
</div>
)
})
and more
if you are using mobx
very good! You can replace my incomplete version mini-mobx to real mobx🤣
config.ts
// ...
import * as mobx from 'mobx'
initSetting({
mobx,
// ...
})
App.tsx
// use mobx-react
// import { observer } from '@apad/setting-panel/react'
import { observer } from 'mobx-react'
export default observer(() => {
// ...
})
you are not using react framework
I recommend to use preact version, It is smaller than the full react version
// import { initSetting, config } from '@apad/setting-panel'
import { initSetting, config } from '@apad/setting-panel/preact'
// ...
0.2.2
10 months ago
0.2.1
11 months ago
0.2.0
1 year ago
0.1.10
1 year ago
0.1.9
1 year ago
0.1.8
1 year ago
0.1.7
1 year ago
0.1.6
1 year ago
0.1.4
1 year ago
0.1.5
1 year ago
0.1.0
2 years ago
0.1.2
2 years ago
0.1.1
2 years ago
0.1.3
2 years ago
0.0.17
2 years ago
0.0.16
2 years ago
0.0.15
2 years ago
0.0.14
2 years ago
0.0.13
2 years ago
0.0.12
2 years ago
0.0.11
2 years ago
0.0.10
2 years ago
0.0.8
2 years ago
0.0.7
2 years ago
0.0.6
2 years ago
0.0.5
2 years ago
0.0.4
2 years ago
0.0.3
2 years ago
0.0.2
2 years ago
0.0.1
2 years ago