Skip to content

Commit

Permalink
UX improvements (v0.0.1-alpha.2) (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
satelllte authored Nov 14, 2023
1 parent dc1b144 commit 13d39b2
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 23 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "displacementx",
"version": "0.0.1-alpha.1",
"version": "0.0.1-alpha.2",
"scripts": {
"dev": "next dev",
"build": "next build",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ export function CanvasSection() {
</output>
</div>
<div className='pt-1'>
<Switch isOn={is8k} setIsOn={onIs8kChange} textOff='4K' textOn='8K' />
<Switch isOn={is8k} setIsOn={onIs8kChange} labels={['4K', '8K']} />
</div>
<div className='flex flex-wrap gap-1 pt-3'>
<Button disabled={isRendering} onClick={render}>
Expand Down
10 changes: 8 additions & 2 deletions src/components/pages/Generator/Generator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,17 @@ import {GitHubLogoIcon} from '@radix-ui/react-icons';
import {CanvasSection} from './CanvasSection';
import {SettingsSection} from './SettingsSection';

import packageJson from '../../../../package.json';
const {version} = packageJson;

export function Generator() {
return (
<div className='mx-auto max-w-screen-2xl'>
<header className='flex flex-row items-center justify-between p-4'>
<h1 className='select-none text-2xl sm:text-3xl'>Displacement X</h1>
<header className='flex flex-row items-start justify-between p-4'>
<div>
<h1 className='select-none text-2xl sm:text-3xl'>Displacement X</h1>
<span className='text-xs text-white/50'>{`v${version}`}</span>
</div>
<Link
className='focus-visible:outline focus-visible:outline-2 focus-visible:outline-red-700'
href='https://github.com/satelllte/displacementx'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,7 @@ export function Group(props: GroupProps) {
{props.title}
</div>
{props.withSwitch && (
<Switch
isOn={props.enabled}
setIsOn={props.setEnabled}
textOff='Off'
textOn='On'
/>
<Switch isOn={props.enabled} setIsOn={props.setEnabled} />
)}
</div>
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,10 @@ export function SettingsSection() {

return (
<section>
<SectionTitle>Settings</SectionTitle>
<div className='flex items-center justify-between'>
<SectionTitle>Settings</SectionTitle>
<Button onClick={randomize}>Randomize</Button>
</div>
<div className='flex flex-col gap-4'>
<Group title='Basics'>
<SliderWrapper
Expand Down Expand Up @@ -286,9 +289,6 @@ export function SettingsSection() {
/>
</Group>
</div>
<div className='pt-2'>
<Button onClick={randomize}>Randomize</Button>
</div>
</section>
);
}
Expand Down
21 changes: 12 additions & 9 deletions src/components/ui/Switch/Switch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,20 @@ import clsx from 'clsx';
import {useId} from 'react';

type SwitchProps = {
readonly textOff: string;
readonly textOn: string;
readonly isOn: boolean;
readonly setIsOn: (checked: boolean) => void;
readonly labels?: [string, string];
};

export function Switch({textOff, textOn, isOn, setIsOn}: SwitchProps) {
export function Switch({labels, isOn, setIsOn}: SwitchProps) {
const id = useId();
return (
<div className='flex items-center gap-2'>
<Label htmlFor={id} isActive={!isOn}>
{textOff}
</Label>
{labels && (
<Label htmlFor={id} isActive={!isOn}>
{labels[0]}
</Label>
)}
<RadixSwitch.Root
id={id}
checked={isOn}
Expand All @@ -24,9 +25,11 @@ export function Switch({textOff, textOn, isOn, setIsOn}: SwitchProps) {
>
<RadixSwitch.Thumb className='block h-full w-4 bg-white shadow-[0_2px_2px] shadow-black transition-transform duration-100 will-change-transform data-[state=checked]:translate-x-full' />
</RadixSwitch.Root>
<Label htmlFor={id} isActive={isOn}>
{textOn}
</Label>
{labels && (
<Label htmlFor={id} isActive={isOn}>
{labels[1]}
</Label>
)}
</div>
);
}
Expand Down

0 comments on commit 13d39b2

Please sign in to comment.