Merge branch 'main' into subprojects

This commit is contained in:
Uriel authored and GitHub committed 2023-07-01 23:05:57 -07:00
commit 9e650dad08
11 files changed
+439 -239

No files matched your search

+34 -12
View File
@@ -1,6 +1,11 @@
import classNames from 'classnames';
import { useEffect, useState } from 'react';
import { Control, Controller } from 'react-hook-form';
import {
Control,
Controller,
UseFormGetValues,
useWatch,
} from 'react-hook-form';
import { a11yClick } from '../utils/a11y';
export interface DropdownItem {
@@ -17,6 +22,7 @@ export function Dropdown({
display = 'fit',
placeholder,
control,
getValues,
name,
items = [],
}: {
@@ -26,13 +32,29 @@ export function Dropdown({
display?: 'fit' | 'block';
placeholder: string;
control: Control<any>;
getValues: UseFormGetValues<any>;
name: string;
items: DropdownItem[];
}) {
const itemRefs: Record<string, HTMLLIElement> = {};
const [isOpen, setOpen] = useState(false);
const formValue = {
...{ value: useWatch({ control, name }) as string },
...{ value: getValues(name) as string },
};
useEffect(() => {
if (!isOpen) return;
const curItem = itemRefs[formValue.value];
const dropdownParent = curItem
? (curItem.closest('.dropdown-scroll') as HTMLElement | null)
: null;
if (curItem && dropdownParent) {
dropdownParent.scroll({
top: curItem.offsetTop - dropdownParent.offsetHeight / 2,
});
}
function onWheelEvent() {
if (isOpen && !document.querySelector('div.dropdown-scroll:hover')) {
setOpen(false);
@@ -55,9 +77,9 @@ export function Dropdown({
const isInDropdownScroll = document
.querySelector('div.dropdown-scroll')
?.contains(event.target as HTMLDivElement);
const isInDropdown = document
.querySelector('div.dropdown')
?.contains(event.target as HTMLDivElement);
const isInDropdown = !!(event.target as HTMLDivElement).closest(
'.dropdown'
);
if (isOpen && !isInDropdownScroll && !isInDropdown) {
setOpen(false);
}
@@ -151,21 +173,19 @@ export function Dropdown({
alignment === 'left' && 'left-0'
)}
>
<ul className="py-1 text-sm flex flex-col ">
<ul className="py-1 text-sm flex flex-col">
{items.map((item) => (
<li
className={classNames(
'py-2 px-4 min-w-max cursor-pointer',
variant == 'primary' &&
'hover:bg-background-50 text-background-20 hover:text-background-10',
'checked-hover:bg-background-50 text-background-20 ' +
'checked-hover:text-background-10',
variant == 'secondary' &&
'hover:bg-background-60 text-background-20 hover:text-background-10',
'checked-hover:bg-background-60 text-background-20 ' +
'checked-hover:text-background-10',
variant == 'tertiary' &&
value !== item.value &&
'bg-accent-background-30 hover:bg-accent-background-20',
variant == 'tertiary' &&
value === item.value &&
'bg-accent-background-20'
'bg-accent-background-30 checked-hover:bg-accent-background-20'
)}
onClick={() => {
onChange(item.value);
@@ -176,8 +196,10 @@ export function Dropdown({
onChange(item.value);
setOpen(false);
}}
ref={(ref) => (ref ? (itemRefs[item.value] = ref) : {})}
key={item.value}
tabIndex={0}
data-checked={item.value === value}
>
{item.label}
</li>
+6 -3
View File
@@ -15,9 +15,11 @@ export function LangSelector({
const { changeLocales } = useContext(LangContext);
const { l10n } = useLocalization();
const { config, setConfig } = useConfig();
const { control, watch, handleSubmit } = useForm<{ lang: string }>({
defaultValues: { lang: config?.lang || 'en' },
});
const { control, watch, handleSubmit, getValues } = useForm<{ lang: string }>(
{
defaultValues: { lang: config?.lang || 'en' },
}
);
const languagesItems = useMemo(
() => langs.map(({ key, name }) => ({ label: name, value: key })),
@@ -37,6 +39,7 @@ export function LangSelector({
return (
<Dropdown
control={control}
getValues={getValues}
name="lang"
placeholder={l10n.getString(
'settings-general-interface-lang-placeholder'
+19 -3
View File
@@ -1,11 +1,27 @@
export function ArrowDownIcon() {
export function ArrowDownIcon({ size = 24 }: { size?: number }) {
return (
<svg
xmlns="http://www.w3.org/2000/svg"
xmlnsXlink="http://www.w3.org/1999/xlink"
version="1.1"
width="24"
height="24"
width={size}
height={size}
viewBox="0 0 24 24"
>
<path d="M7.41,8.58L12,13.17L16.59,8.58L18,10L12,16L6,10L7.41,8.58Z" />
</svg>
);
}
export function ArrowUpIcon({ size = 24 }: { size: number }) {
return (
<svg
xmlns="http://www.w3.org/2000/svg"
xmlnsXlink="http://www.w3.org/1999/xlink"
version="1.1"
width={size}
height={size}
className="rotate-180"
viewBox="0 0 24 24"
>
<path d="M7.41,8.58L12,13.17L16.59,8.58L18,10L12,16L6,10L7.41,8.58Z" />
@@ -1,6 +1,14 @@
import { useLocalization } from '@fluent/react';
import classNames from 'classnames';
import { MouseEventHandler, ReactNode, useEffect } from 'react';
import {
MouseEventHandler,
ReactNode,
useEffect,
useRef,
UIEvent,
MouseEvent,
useMemo,
} from 'react';
import {
LabelType,
ProportionChangeType,
@@ -8,7 +16,7 @@ import {
} from '../../../../hooks/manual-proportions';
import { useLocaleConfig } from '../../../../i18n/config';
import { Typography } from '../../../commons/Typography';
import { useBreakpoint } from '../../../../hooks/breakpoint';
import { ArrowDownIcon, ArrowUpIcon } from '../../../commons/icon/ArrowIcons';
function IncrementButton({
children,
@@ -21,7 +29,8 @@ function IncrementButton({
<div
onClick={onClick}
className={classNames(
'p-3 rounded-lg xs:w-16 xs:h-16 mobile:w-10 flex flex-col justify-center items-center bg-background-60 hover:bg-opacity-50'
'p-3 rounded-lg xs:w-16 xs:h-16 mobile:w-10 flex flex-col justify-center items-center',
'bg-background-60 hover:bg-opacity-50 active:bg-accent-background-30'
)}
>
<Typography variant="mobile-title" bold>
@@ -40,25 +49,25 @@ export function BodyProportions({
type: 'linear' | 'ratio';
variant: 'onboarding' | 'alone';
}) {
const { isMobile } = useBreakpoint('mobile');
const [bodyParts, _ratioMode, currentSelection, dispatch, setRatioMode] =
useManualProportions();
const { currentLocales } = useLocaleConfig();
const { bodyParts, dispatch, state, setRatioMode } = useManualProportions();
const { l10n } = useLocalization();
const { currentLocales } = useLocaleConfig();
const srcollerRef = useRef<HTMLDivElement | null>(null);
const cmFormat = Intl.NumberFormat(currentLocales, {
style: 'unit',
unit: 'centimeter',
maximumFractionDigits: 1,
});
const configFormat = Intl.NumberFormat(currentLocales, {
signDisplay: 'always',
maximumFractionDigits: 1,
});
const percentageFormat = Intl.NumberFormat(currentLocales, {
style: 'percent',
maximumFractionDigits: 1,
});
const configFormat = Intl.NumberFormat(currentLocales, {
signDisplay: 'always',
maximumFractionDigits: 1,
});
useEffect(() => {
if (type === 'linear') {
@@ -68,131 +77,229 @@ export function BodyProportions({
}
}, [type]);
useEffect(() => {
if (srcollerRef.current && bodyParts.length > 0) {
moveToIndex(1);
}
}, [srcollerRef, bodyParts.length]);
const handleUIEvent = (e: UIEvent<HTMLDivElement>) => {
const target = e.target as HTMLDivElement;
const itemHeight = target.offsetHeight / 3;
const atSnappingPoint = target.scrollTop % itemHeight === 0;
if (atSnappingPoint) {
const index = target.scrollTop / itemHeight;
const elem = srcollerRef.current?.childNodes[index + 1] as HTMLDivElement;
const id = elem.getAttribute('itemid');
if (id) selectNew(id);
}
};
const clickPart = (id: string) => (e: MouseEvent<HTMLDivElement>) => {
const target = e.target as HTMLDivElement;
target.scrollIntoView({ behavior: 'smooth', block: 'center' });
selectNew(id);
};
const moveToIndex = (index: number, smooth = true) => {
// We add one because of the offset placeholder
const elem = srcollerRef.current?.childNodes[index + 1] as HTMLDivElement;
elem?.scrollIntoView({
behavior: smooth ? 'smooth' : 'auto',
block: 'center',
});
const id = elem.getAttribute('itemid');
if (id) selectNew(id);
};
const selectNew = (id: string) => {
const part = bodyParts.find(({ label }) => label === id);
if (!part) return;
const { value: originalValue, label, type, ...props } = part;
const value =
'index' in props && props.index !== undefined
? props.bones[props.index].value
: originalValue;
switch (type) {
case LabelType.Bone: {
if (!('bone' in props)) throw 'unreachable';
dispatch({
...props,
label,
value,
type: ProportionChangeType.Bone,
});
break;
}
case LabelType.Group: {
if (!('bones' in props)) throw 'unreachable';
dispatch({
...props,
label,
value,
type: ProportionChangeType.Group,
index: undefined,
parentLabel: label,
});
break;
}
case LabelType.GroupPart: {
if (!('index' in props)) throw 'unreachable';
dispatch({
...props,
label,
// If this isn't done, we are replacing total
// with percentage value
value: originalValue,
type: ProportionChangeType.Group,
index: props.index,
});
}
}
};
const seletedLabel = useMemo(() => {
return bodyParts.find(({ label }) => label === state.currentLabel);
}, [state]);
const move = (action: 'next' | 'prev') => {
const elem = srcollerRef.current?.querySelector(
`div[itemid=${state.currentLabel}]`
);
const moveId = (id: string, elem: HTMLDivElement) => {
elem?.scrollIntoView({
behavior: 'smooth',
block: 'center',
});
selectNew(id);
};
if (action === 'prev') {
const prevElem = elem?.previousSibling as HTMLDivElement;
const prevId = prevElem.getAttribute('itemid');
if (!prevId) return;
moveId(prevId, prevElem);
}
if (action === 'next') {
const nextElem = elem?.nextSibling as HTMLDivElement;
const nextId = nextElem.getAttribute('itemid');
if (!nextId) return;
moveId(nextId, nextElem);
}
};
return (
<div className="relative w-full">
<div
className={classNames(
'flex flex-col xs:overflow-y-scroll xs:overflow-x-hidden xs:max-h-[450px] xs:h-[54vh]',
'w-full px-1 gap-3 xs:gradient-mask-b-90'
)}
>
<>
{bodyParts.map(({ label, type, value: originalValue, ...props }) => {
const value =
'index' in props && props.index !== undefined
? props.bones[props.index].value
: originalValue;
const selected = isMobile || currentSelection.label === label;
const selectNew = () => {
switch (type) {
case LabelType.Bone: {
if (!('bone' in props)) throw 'unreachable';
dispatch({
...props,
label,
value,
type: ProportionChangeType.Bone,
});
break;
}
case LabelType.Group: {
if (!('bones' in props)) throw 'unreachable';
dispatch({
...props,
label,
value,
type: ProportionChangeType.Group,
index: undefined,
parentLabel: label,
});
break;
}
case LabelType.GroupPart: {
if (!('index' in props)) throw 'unreachable';
dispatch({
...props,
label,
// If this isn't done, we are replacing total
// with percentage value
value: originalValue,
type: ProportionChangeType.Group,
index: props.index,
});
(bodyParts.length > 0 && (
<div className="flex w-full gap-3">
<div className="flex items-center mobile:justify-center mobile:flex-col gap-2 my-2">
{!precise && (
<div className="mobile:order-2">
<IncrementButton
onClick={() =>
seletedLabel?.type === LabelType.GroupPart
? dispatch({
type: ProportionChangeType.Ratio,
value: -0.05,
})
: dispatch({
type: ProportionChangeType.Linear,
value: -5,
})
}
>
{configFormat.format(-5)}
</IncrementButton>
</div>
)}
<div className="mobile:order-1">
<IncrementButton
onClick={() =>
seletedLabel?.type === LabelType.GroupPart
? dispatch({
type: ProportionChangeType.Ratio,
value: -0.01,
})
: dispatch({
type: ProportionChangeType.Linear,
value: -1,
})
}
};
>
{configFormat.format(-1)}
</IncrementButton>
</div>
{precise && (
<div className="mobile:order-2">
<IncrementButton
onClick={() =>
seletedLabel?.type === LabelType.GroupPart
? dispatch({
type: ProportionChangeType.Ratio,
value: -0.005,
})
: dispatch({
type: ProportionChangeType.Linear,
value: -0.5,
})
}
>
{configFormat.format(-0.5)}
</IncrementButton>
</div>
)}
</div>
<div className="flex flex-grow flex-col">
<div className="flex justify-center">
<div
onClick={() => move('prev')}
className={classNames(
'h-12 w-32 rounded-lg bg-background-60 flex flex-col justify-center',
'items-center fill-background-10',
srcollerRef?.current?.scrollTop ?? 0 > 0
? 'opacity-100 active:bg-accent-background-30'
: 'opacity-50'
)}
>
<ArrowUpIcon size={32}></ArrowUpIcon>
</div>
</div>
<div
ref={srcollerRef}
onScroll={handleUIEvent}
className="h-60 flex-grow flex-col overflow-y-auto snap-y snap-mandatory snap-always no-scrollbar"
>
<div className="h-20 snap-start "></div>
{bodyParts.map((part) => {
const { label, value: originalValue, type, ...props } = part;
const value =
'index' in props && props.index !== undefined
? props.bones[props.index].value
: originalValue;
return (
<div className="flex" key={label}>
const selected = state.currentLabel === label;
return (
<div
className={classNames(
'flex gap-2 transition-opacity duration-300',
!selected && 'opacity-0 pointer-events-none'
)}
>
{!precise && (
<IncrementButton
onClick={() => {
selectNew();
return type === LabelType.GroupPart
? dispatch({
type: ProportionChangeType.Ratio,
value: -0.05,
})
: dispatch({
type: ProportionChangeType.Linear,
value: -5,
});
}}
>
{configFormat.format(-5)}
</IncrementButton>
)}
<IncrementButton
onClick={() => {
selectNew();
return type === LabelType.GroupPart
? dispatch({
type: ProportionChangeType.Ratio,
value: -0.01,
})
: dispatch({
type: ProportionChangeType.Linear,
value: -1,
});
}}
>
{configFormat.format(-1)}
</IncrementButton>
{precise && (
<IncrementButton
onClick={() => {
selectNew();
return type === LabelType.GroupPart
? dispatch({
type: ProportionChangeType.Ratio,
value: -0.005,
})
: dispatch({
type: ProportionChangeType.Linear,
value: -0.5,
});
}}
>
{configFormat.format(-0.5)}
</IncrementButton>
)}
</div>
<div
className="flex flex-grow flex-col px-2"
onClick={selectNew}
key={label}
itemID={label}
onClick={clickPart(label)}
className="snap-start h-20 flex-col flex justify-center"
>
<div
key={label}
className={classNames(
'p-3 rounded-lg xs:h-16 flex w-full items-center justify-between xs:px-6 mobile:px-3 transition-colors duration-300 bg-background-60',
(selected && 'opacity-100') || 'opacity-50'
'h-16 p-3 rounded-lg flex w-full items-center justify-between px-6 transition-colors',
'duration-300 bg-background-60',
(selected && 'opacity-100') ||
'opacity-50 active:bg-accent-background-30'
)}
>
<Typography variant="section-title" bold>
@@ -211,70 +318,87 @@ export function BodyProportions({
</Typography>
</div>
</div>
<div
className={classNames(
'flex gap-2 transition-opacity duration-300',
!selected && 'opacity-0 pointer-events-none'
)}
>
{precise && (
<IncrementButton
onClick={() => {
selectNew();
return type === LabelType.GroupPart
? dispatch({
type: ProportionChangeType.Ratio,
value: 0.005,
})
: dispatch({
type: ProportionChangeType.Linear,
value: 0.5,
});
}}
>
{configFormat.format(+0.5)}
</IncrementButton>
)}
<IncrementButton
onClick={() => {
selectNew();
return type === LabelType.GroupPart
? dispatch({
type: ProportionChangeType.Ratio,
value: 0.01,
})
: dispatch({
type: ProportionChangeType.Linear,
value: 1,
});
}}
>
{configFormat.format(+1)}
</IncrementButton>
{!precise && (
<IncrementButton
onClick={() => {
selectNew();
return type === LabelType.GroupPart
? dispatch({
type: ProportionChangeType.Ratio,
value: 0.05,
})
: dispatch({
type: ProportionChangeType.Linear,
value: 5,
});
}}
>
{configFormat.format(+5)}
</IncrementButton>
)}
</div>
</div>
);
})}
</>
);
})}
<div className="h-20 snap-start"></div>
</div>
<div className="flex justify-center">
<div
onClick={() => move('next')}
className={classNames(
'h-12 w-32 rounded-lg bg-background-60 flex flex-col justify-center',
'items-center fill-background-10',
srcollerRef?.current?.scrollTop !==
(srcollerRef?.current?.scrollHeight ?? 0) -
(srcollerRef?.current?.offsetHeight ?? 0)
? 'opacity-100 active:bg-accent-background-30'
: 'opacity-50'
)}
>
<ArrowDownIcon size={32}></ArrowDownIcon>
</div>
</div>
</div>
<div className="flex items-center mobile:justify-center mobile:flex-col gap-2">
{precise && (
<div className="mobile:order-2">
<IncrementButton
onClick={() =>
seletedLabel?.type === LabelType.GroupPart
? dispatch({
type: ProportionChangeType.Ratio,
value: 0.005,
})
: dispatch({
type: ProportionChangeType.Linear,
value: 0.5,
})
}
>
{configFormat.format(+0.5)}
</IncrementButton>
</div>
)}
<div className="mobile:order-1">
<IncrementButton
onClick={() =>
seletedLabel?.type === LabelType.GroupPart
? dispatch({
type: ProportionChangeType.Ratio,
value: 0.01,
})
: dispatch({
type: ProportionChangeType.Linear,
value: 1,
})
}
>
{configFormat.format(+1)}
</IncrementButton>
</div>
{!precise && (
<div className="mobile:order-2">
<IncrementButton
onClick={() =>
seletedLabel?.type === LabelType.GroupPart
? dispatch({
type: ProportionChangeType.Ratio,
value: 0.05,
})
: dispatch({
type: ProportionChangeType.Linear,
value: 5,
})
}
>
{configFormat.format(+5)}
</IncrementButton>
</div>
)}
</div>
</div>
</div>
)) || <></>
);
}
@@ -66,8 +66,8 @@ export function ManualProportionsPage() {
<>
<div className="flex flex-col gap-5 h-full items-center w-full xs:justify-center overflow-y-auto relative">
<div className="flex flex-col w-full h-full xs:max-w-5xl xs:justify-center">
<div className="flex gap-8 justify-center">
<div className="flex flex-col w-full xs:max-w-2xl gap-3 items-center">
<div className="flex gap-8 justify-center h-full xs:items-center">
<div className="flex flex-col w-full xs:max-w-2xl gap-3 items-center mobile:justify-around">
<div className="flex flex-col">
<Typography variant="main-title">
{l10n.getString('onboarding-manual_proportions-title')}
@@ -92,19 +92,20 @@ export function ManualProportionsPage() {
</div>
)}
</div>
<BodyProportions
precise={precise}
type={ratio ? 'ratio' : 'linear'}
variant={state.alonePage ? 'alone' : 'onboarding'}
></BodyProportions>
<div className="w-full px-2">
<BodyProportions
precise={precise}
type={ratio ? 'ratio' : 'linear'}
variant={state.alonePage ? 'alone' : 'onboarding'}
></BodyProportions>
</div>
</div>
<div className="flex-col flex-grow gap-3 rounded-xl fill-background-50 items-center hidden md:flex">
<PersonFrontIcon width={200}></PersonFrontIcon>
</div>
</div>
{!isMobile && (
<div className="flex gap-3 mt-5 mx-4">
<div className="flex gap-3 my-5 mx-4 justify-between">
<ButtonsControl></ButtonsControl>
</div>
)}
@@ -38,7 +38,7 @@ export function SettingSelectorMobile() {
},
];
const { control, watch, handleSubmit, setValue } = useForm<{
const { control, watch, handleSubmit, setValue, getValues } = useForm<{
link: string;
}>({
defaultValues: { link: links[0].value.url },
@@ -65,6 +65,7 @@ export function SettingSelectorMobile() {
<div className="fixed top-12 z-50 px-4 w-full">
<Dropdown
control={control}
getValues={getValues}
display="block"
items={links.map(({ label, value: { url: value } }) => ({
label,
@@ -17,9 +17,19 @@ export function SettingsPageLayout({
if (!pageRef.current || !typedState || !typedState.scrollTo) {
return;
}
const elem = pageRef.current.querySelector(`#${typedState.scrollTo}`);
const elem = pageRef.current.querySelector(
`#${typedState.scrollTo}`
) as HTMLElement | null;
if (elem) {
elem.scrollIntoView({ behavior: 'smooth', block: 'start' });
// stupid way of doing this, just get the closest overflow-y-auto
// usually its just the parentElem
const closestScroll = elem.closest(
'.overflow-y-auto'
) as HTMLElement | null;
if (closestScroll) {
// The 45 is just enough padding for making the scroll look perfect
closestScroll.scroll({ top: elem.offsetTop - 45, behavior: 'smooth' });
}
}
}, [state]);
+6 -3
View File
@@ -51,9 +51,10 @@ export function Serial() {
const [tryFactoryReset, setTryFactoryReset] = useState(false);
const { control, watch, handleSubmit, reset } = useForm<SerialForm>({
defaultValues: { port: 'Auto' },
});
const { control, watch, handleSubmit, reset, getValues } =
useForm<SerialForm>({
defaultValues: { port: 'Auto' },
});
const { port } = watch();
@@ -234,6 +235,7 @@ export function Serial() {
{isMobile && (
<Dropdown
control={control}
getValues={getValues}
name="port"
display="block"
placeholder={l10n.getString(
@@ -250,6 +252,7 @@ export function Serial() {
{!isMobile && (
<Dropdown
control={control}
getValues={getValues}
name="port"
display="fit"
placeholder={l10n.getString('settings-serial-serial_select')}
+16 -13
View File
@@ -64,7 +64,7 @@ export interface BoneState {
type: BoneType.Single;
bone: SkeletonBone;
value: number;
label: string;
currentLabel: string;
}
export interface GroupState {
@@ -77,7 +77,7 @@ export interface GroupState {
value: number;
}[];
value: number;
label: string;
currentLabel: string;
index?: number;
parentLabel: string;
}
@@ -87,6 +87,7 @@ function reducer(state: ProportionState, action: ProportionChange): ProportionSt
case ProportionChangeType.Bone: {
return {
...action,
currentLabel: action.label,
type: BoneType.Single,
};
}
@@ -94,6 +95,7 @@ function reducer(state: ProportionState, action: ProportionChange): ProportionSt
case ProportionChangeType.Group: {
return {
...action,
currentLabel: action.label,
type: BoneType.Group,
};
}
@@ -114,7 +116,7 @@ function reducer(state: ProportionState, action: ProportionChange): ProportionSt
case ProportionChangeType.Ratio: {
if (state.type === BoneType.Single || state.index === undefined) {
throw new Error(`Unexpected increase of bone ${state.label}`);
throw new Error(`Unexpected increase of bone ${state.currentLabel}`);
}
const newState: GroupState = JSON.parse(JSON.stringify(state));
@@ -192,16 +194,16 @@ export const INVALID_BONE: BoneState = {
type: BoneType.Single,
bone: SkeletonBone.NONE,
value: 0,
label: 'invalid-bone',
currentLabel: 'invalid-bone',
};
export function useManualProportions(): [
Label[],
boolean,
ProportionState,
(change: ProportionChange) => void,
(ratio: boolean) => void
] {
export function useManualProportions(): {
bodyParts: Label[];
ratioMode: boolean;
state: ProportionState;
dispatch: (change: ProportionChange) => void;
setRatioMode: (ratio: boolean) => void;
} {
const { useRPCPacket, sendRPCPacket } = useWebsocketAPI();
const [config, setConfig] = useState<Omit<SkeletonConfigResponseT, 'pack'> | null>(
null
@@ -278,6 +280,7 @@ export function useManualProportions(): [
useLayoutEffect(() => {
dispatch({
...INVALID_BONE,
label: INVALID_BONE.currentLabel,
type: ProportionChangeType.Bone,
});
}, [ratio]);
@@ -315,7 +318,7 @@ export function useManualProportions(): [
const part = bodyParts.find(
(it) =>
it.type === LabelType.Group &&
(it.label === state.label || it.label === state.parentLabel)
(it.label === state.currentLabel || it.label === state.parentLabel)
) as GroupLabel | undefined;
// Check if we found the group we were looking for
@@ -345,7 +348,7 @@ export function useManualProportions(): [
setConfig(conf);
}, [state]);
return [bodyParts, ratio, state, dispatch, setRatio];
return { bodyParts, ratioMode: ratio, state, dispatch, setRatioMode: setRatio };
}
function roundedStep(value: number, step: number, add: boolean): number {
+11
View File
@@ -257,6 +257,17 @@ body {
height: 100%;
}
/* Hide scrollbar for Chrome, Safari and Opera */
.no-scrollbar::-webkit-scrollbar {
display: none;
}
/* Hide scrollbar for IE, Edge and Firefox */
.no-scrollbar {
-ms-overflow-style: none; /* IE and Edge */
scrollbar-width: none; /* Firefox */
}
::-webkit-scrollbar {
width: 8px;
height: 8px;
+6
View File
@@ -230,6 +230,9 @@ const config = {
'trans-flag': `linear-gradient(135deg, ${colors['trans-blue'][800]} 40%, ${colors['trans-blue'][700]} 40% 70%, ${colors['trans-blue'][600]} 70% 100%)`,
},
},
data: {
checked: 'checked=true'
}
},
plugins: [
forms,
@@ -250,6 +253,9 @@ const config = {
'.text-standard-bold': textConfig(rem(12), 700),
});
}),
plugin(function({ addVariant }) {
addVariant('checked-hover', ['&:hover', '&[data-checked=true]'])
})
],
} satisfies Config