Skip to content

Commit

Permalink
fix: align text fields with buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
bmsuseluda committed Mar 22, 2024
1 parent f60026c commit 660760e
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 31 deletions.
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
import { CheckboxRow } from ".";
import { Checkbox } from "~/components/Checkbox";
import { Label } from "~/components/Label";
import { CheckboxLabel } from ".";

import type { Meta, StoryObj } from "@storybook/react";
import { Checkbox } from "~/components/Checkbox";

const meta = {
component: CheckboxRow,
} satisfies Meta<typeof CheckboxRow>;
component: CheckboxLabel,
} satisfies Meta<typeof CheckboxLabel>;

export default meta;
type Story = StoryObj<typeof meta>;

export const Checked: Story = {
render: (args) => (
<form>
<CheckboxRow {...args}>
<CheckboxLabel {...args}>
<Checkbox
id="alwaysGameNames"
name="alwaysGameNames"
defaultChecked={true}
/>
<Label htmlFor="alwaysGameNames">Always show game names</Label>
</CheckboxRow>
Always show game names
</CheckboxLabel>
</form>
),
};

export const Unchecked: Story = {
render: (args) => (
<form>
<CheckboxRow {...args}>
<CheckboxLabel {...args}>
<Checkbox
id="alwaysGameNames"
name="alwaysGameNames"
defaultChecked={false}
/>
<Label htmlFor="alwaysGameNames">Always show game names</Label>
</CheckboxRow>
Always show game names
</CheckboxLabel>
</form>
),
};
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
import * as LabelPrimitive from "@radix-ui/react-label";
import { styled } from "../../../styled-system/jsx";

// TODO: Check if this could be replaced with formrow
export const CheckboxRow = styled("fieldset", {
export const CheckboxLabel = styled(LabelPrimitive.Root, {
base: {
display: "flex",
display: "inline-flex",
flexDirection: "row",
alignItems: "center",
gap: "1",
padding: "1",
padding: 1,
margin: 0,
borderRounded: true,
borderWidth: "1px",
borderColor: "transparent",
color: "color",

"&:hover": {
cursor: "pointer",
},

"&:focus-within": {
borderColor: "accent",
Expand Down
1 change: 1 addition & 0 deletions app/components/Dialog/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const DialogContent = styled("div", {
height: "60vh",
maxHeight: "90vh",
animation: "scaleUp 150ms",
overflow: "clip",
"&:focus": { outline: "none" },
},

Expand Down
5 changes: 4 additions & 1 deletion app/components/FormRow/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ export const FormRow = styled("fieldset", {
display: "flex",
flexDirection: "column",
gap: "1",
padding: "1",
paddingTop: "1",
paddingRight: "1",
paddingBottom: "1",
paddingLeft: "0",
margin: 0,
borderRounded: true,
borderWidth: "1px",
Expand Down
1 change: 1 addition & 0 deletions app/components/GameGrid/components/Game/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const Wrapper = styled("li", {
position: "relative",
minWidth: "200px",
maxWidth: "300px",
transition: "width 0.1s ease-in-out",
},
});

Expand Down
24 changes: 11 additions & 13 deletions app/customRoutes/categories.$category.settings.appearance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@ import { IoMdSave } from "react-icons/io";
import { Form, useLoaderData } from "@remix-run/react";
import { Button } from "~/components/Button";
import { FormBox } from "~/components/FormBox";
import { Label } from "~/components/Label";
import { ListActionBarLayout } from "~/components/layouts/ListActionBarLayout";
import { readAppearance, writeAppearance } from "~/server/settings.server";
import { Checkbox } from "~/components/Checkbox";
import type { Appearance } from "~/types/jsonFiles/settings/appearance";
import { IconChildrenWrapper } from "~/components/IconChildrenWrapper";
import { SettingsIcon } from "~/components/SettingsIcon";
import { useFullscreen } from "~/hooks/useFullscreen";
import { CheckboxRow } from "~/components/CheckboxRow";
import { CheckboxLabel } from "~/components/CheckboxLabel";
import type { ElementRef } from "react";
import { useCallback, useRef } from "react";
import type { Result } from "~/hooks/useGamepadsOnGrid";
Expand Down Expand Up @@ -138,10 +137,11 @@ export default function Index() {
>
<Form method="POST">
<ListActionBarLayout.ListActionBarContainer
scrollSmooth
list={
<FormBox ref={entryListRef}>
<li>
<CheckboxRow>
<CheckboxLabel>
<Checkbox
id="fullscreen"
name="fullscreen"
Expand All @@ -152,32 +152,30 @@ export default function Index() {
}
ref={entriesRefCallback(0)}
/>
<Label htmlFor="fullscreen">Fullscreen</Label>
</CheckboxRow>
Fullscreen
</CheckboxLabel>
</li>
<li>
<CheckboxRow>
<CheckboxLabel>
<Checkbox
id="alwaysGameNames"
name="alwaysGameNames"
defaultChecked={alwaysGameNames}
ref={entriesRefCallback(1)}
/>
<Label htmlFor="alwaysGameNames">
Always show game names
</Label>
</CheckboxRow>
Always show game names
</CheckboxLabel>
</li>
<li>
<CheckboxRow>
<CheckboxLabel>
<Checkbox
id="collapseSidebar"
name="collapseSidebar"
defaultChecked={collapseSidebar}
ref={entriesRefCallback(2)}
/>
<Label htmlFor="collapseSidebar">Collapse sidebar</Label>
</CheckboxRow>
Collapse sidebar
</CheckboxLabel>
</li>
</FormBox>
}
Expand Down
2 changes: 1 addition & 1 deletion app/customRoutes/categories.$category.settings.general.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export const action = async ({ request }: ActionFunctionArgs) => {
const categories = readCategories();

if (categories?.length > 0) {
throw redirect(`/categories/${categories[0].id}/settings/general`);
return redirect(`/categories/${categories[0].id}/settings/general`);
}
}

Expand Down
1 change: 0 additions & 1 deletion panda.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ const borderRounded = defineUtility({
return {
borderRadius: token("radii.1"),
position: "relative",
overflow: "clip",
};
}
return {};
Expand Down

0 comments on commit 660760e

Please sign in to comment.