fix: Better only input
This commit is contained in:
parent
cc3d9e74a8
commit
9a7911a816
2 changed files with 24 additions and 16 deletions
|
@ -1,4 +1,5 @@
|
|||
import React, { useMemo, useCallback, useState } from 'react'
|
||||
import { i18n } from '@freesewing/collection'
|
||||
import { designOptionType, round, measurementAsUnits, measurementAsMm } from '@freesewing/utils'
|
||||
import { menuRoundPct } from '../../lib/index.mjs'
|
||||
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*/
|
||||
export const MenuOnlySettingInput = (props) => {
|
||||
const { config } = props
|
||||
config.sideBySide = true
|
||||
config.titleMethod = (entry, t) => {
|
||||
const chunks = entry.split('.')
|
||||
return <span className="tw-font-medium tw-text-base">{t(`${chunks[0]}:${chunks[1]}`)}</span>
|
||||
}
|
||||
config.valueMethod = (entry) => (
|
||||
<span className="tw-text-sm">{capitalize(entry.split('.')[0])}</span>
|
||||
)
|
||||
config.dense = true
|
||||
// Sort alphabetically (translated)
|
||||
const order = []
|
||||
//config.sideBySide = true
|
||||
//config.titleMethod = (entry, t) => {
|
||||
// const chunks = entry.split('.')
|
||||
// return <span className="tw-font-medium tw-text-base">{entry}</span> //t(`${chunks[0]}:${chunks[1]}`)}</span>
|
||||
//}
|
||||
//config.valueMethod = (entry) => (
|
||||
// <span className="tw-text-sm">{capitalize(entry.split('.')[0])}</span>
|
||||
//)
|
||||
//config.dense = true
|
||||
// Sort alphabetically
|
||||
//const order = []
|
||||
//order.sort()
|
||||
console.log(i18n)
|
||||
config.list = config.list.sort()
|
||||
config.choiceTitles = {}
|
||||
for (const part of config.list) {
|
||||
const [ns, name] = part.split('.')
|
||||
order.push(`${ns}:${name}|${part}`)
|
||||
config.choiceTitles[part] = `${ns}:${name}`
|
||||
const [design, name] = part.split('.')
|
||||
config.choiceTitles[part] = (
|
||||
<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">»</span>
|
||||
{i18n[design].en.p[name]}
|
||||
</span>
|
||||
)
|
||||
}
|
||||
order.sort()
|
||||
config.list = order.map((entry) => entry.split('|')[1])
|
||||
|
||||
return <MenuListInput {...props} />
|
||||
}
|
||||
|
|
|
@ -199,6 +199,7 @@ export function menuCoreSettingsStructure({ units = 'metric', sabool = false, pa
|
|||
icon: ExpandIcon,
|
||||
},
|
||||
only: {
|
||||
dense: true,
|
||||
title: 'Only included selected pattern parts',
|
||||
ux: config.uxLevels.core.only,
|
||||
dflt: false,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue