wip colored button options

This commit is contained in:
Vitaly Turovsky 2025-01-27 19:49:27 +03:00
commit 91ef3ccd3c
3 changed files with 8 additions and 2 deletions

View file

@ -295,7 +295,7 @@ class MainScene extends BasePlaygroundScene {
}
}
worldView!.setBlockStateId(this.targetPos, block.stateId!)
worldView!.setBlockStateId(this.targetPos, block.stateId)
console.log('up stateId', block.stateId)
this.params.metadata = block.metadata
this.metadataGui.updateDisplay()

View file

@ -8,6 +8,7 @@ import PixelartIcon from './PixelartIcon'
interface Props extends React.ComponentProps<'button'> {
label?: string
postLabel?: React.ReactNode
icon?: string
children?: React.ReactNode
inScreen?: boolean
@ -22,7 +23,7 @@ export const ButtonProvider: FC<{ children, onClick }> = ({ children, onClick })
return <ButtonContext.Provider value={{ onClick }}>{children}</ButtonContext.Provider>
}
export default (({ label, icon, children, inScreen, rootRef, type = 'button', ...args }) => {
export default (({ label, icon, children, inScreen, rootRef, type = 'button', postLabel, ...args }) => {
const ctx = useContext(ButtonContext)
const onClick = (e) => {
@ -42,6 +43,7 @@ export default (({ label, icon, children, inScreen, rootRef, type = 'button', ..
<button ref={rootRef} {...args} className={classNames(buttonCss.button, args.className)} onClick={onClick} type={type}>
{icon && <PixelartIcon className={buttonCss.icon} iconName={icon} />}
{label}
{postLabel}
{children}
</button>
</SharedHudVars>

View file

@ -63,6 +63,8 @@ export const OptionButton = ({ item }: { item: Extract<OptionMeta, { type: 'togg
const valuesTitlesMap = useMemo(() => {
if (!item.values) {
return {
// true: <span style={{ color: 'lime' }}>ON</span>,
// false: <span style={{ color: 'red' }}>OFF</span>,
true: 'ON',
false: 'OFF',
}
@ -82,6 +84,8 @@ export const OptionButton = ({ item }: { item: Extract<OptionMeta, { type: 'togg
return <Button
data-setting={item.id}
label={`${item.text}: ${valuesTitlesMap[optionValue]}`}
// label={`${item.text}:`}
// postLabel={valuesTitlesMap[optionValue]}
onClick={async (event) => {
if (disabledReason) {
await showOptionsModal(`The option is unavailable. ${disabledReason}`, [])