1
0
Fork 0

fix: Better only input

This commit is contained in:
joostdecock 2025-01-26 16:03:51 +01:00
parent cc3d9e74a8
commit 9a7911a816
2 changed files with 24 additions and 16 deletions

View file

@ -1,4 +1,5 @@
import React, { useMemo, useCallback, useState } from 'react' import React, { useMemo, useCallback, useState } from 'react'
import { i18n } from '@freesewing/collection'
import { designOptionType, round, measurementAsUnits, measurementAsMm } from '@freesewing/utils' import { designOptionType, round, measurementAsUnits, measurementAsMm } from '@freesewing/utils'
import { menuRoundPct } from '../../lib/index.mjs' import { menuRoundPct } from '../../lib/index.mjs'
import { ButtonFrame, NumberInput } from '@freesewing/react/components/Input' import { ButtonFrame, NumberInput } from '@freesewing/react/components/Input'
@ -389,25 +390,31 @@ const useBoolConfig = (name, config) => {
/** an input for the 'only' setting. toggles individual parts*/ /** an input for the 'only' setting. toggles individual parts*/
export const MenuOnlySettingInput = (props) => { export const MenuOnlySettingInput = (props) => {
const { config } = props const { config } = props
config.sideBySide = true //config.sideBySide = true
config.titleMethod = (entry, t) => { //config.titleMethod = (entry, t) => {
const chunks = entry.split('.') // const chunks = entry.split('.')
return <span className="tw-font-medium tw-text-base">{t(`${chunks[0]}:${chunks[1]}`)}</span> // return <span className="tw-font-medium tw-text-base">{entry}</span> //t(`${chunks[0]}:${chunks[1]}`)}</span>
} //}
config.valueMethod = (entry) => ( //config.valueMethod = (entry) => (
<span className="tw-text-sm">{capitalize(entry.split('.')[0])}</span> // <span className="tw-text-sm">{capitalize(entry.split('.')[0])}</span>
) //)
config.dense = true //config.dense = true
// Sort alphabetically (translated) // Sort alphabetically
const order = [] //const order = []
//order.sort()
console.log(i18n)
config.list = config.list.sort()
config.choiceTitles = {} config.choiceTitles = {}
for (const part of config.list) { for (const part of config.list) {
const [ns, name] = part.split('.') const [design, name] = part.split('.')
order.push(`${ns}:${name}|${part}`) config.choiceTitles[part] = (
config.choiceTitles[part] = `${ns}:${name}` <span>
<span className="tw-font-medium tw-opacity-80 tw-capitalize">{design}</span>
<span className="tw-font-medium tw-opacity-80 tw-capitalize tw-px-2">&raquo;</span>
{i18n[design].en.p[name]}
</span>
)
} }
order.sort()
config.list = order.map((entry) => entry.split('|')[1])
return <MenuListInput {...props} /> return <MenuListInput {...props} />
} }

View file

@ -199,6 +199,7 @@ export function menuCoreSettingsStructure({ units = 'metric', sabool = false, pa
icon: ExpandIcon, icon: ExpandIcon,
}, },
only: { only: {
dense: true,
title: 'Only included selected pattern parts', title: 'Only included selected pattern parts',
ux: config.uxLevels.core.only, ux: config.uxLevels.core.only,
dflt: false, dflt: false,