Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: skeleton, progress-circle #432

Merged
merged 6 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ import { AlertDialog as UIAlertDialog } from "@/seed-design/ui/alert-dialog";

declare module "@stackflow/config" {
interface Register {
Main: {
AlertDialogDefault: {
alert: boolean;
};
}
}

const AlertDialogActivity: ActivityComponentType<"Main"> = ({ params }) => {
const AlertDialogDefaultActivity: ActivityComponentType<"AlertDialogDefault"> = ({ params }) => {
const { alert } = params;
const stack = useStack();
const { pushStep, popStep } = useStepFlow("Main");
const { pushStep, popStep } = useStepFlow("AlertDialogDefault");

const appBarLeft = () => <div>Left</div>;
const appBarRight = () => <div>Right</div>;
Expand Down Expand Up @@ -102,4 +102,6 @@ const AlertDialogActivity: ActivityComponentType<"Main"> = ({ params }) => {
);
};

export default AlertDialogActivity;
export default AlertDialogDefaultActivity;

AlertDialogDefaultActivity.displayName = "AlertDialogDefaultActivity";
2 changes: 2 additions & 0 deletions component-docs/activities/ChipTabsBasicActivity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,5 @@ const ChipTabsBasicActivity: ActivityComponentType<"ChipTabsBasic"> = () => {
};

export default ChipTabsBasicActivity;

ChipTabsBasicActivity.displayName = "ChipTabsBasicActivity";
2 changes: 2 additions & 0 deletions component-docs/activities/TabsAlertActivity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,5 @@ const TabsAlertActivity: ActivityComponentType<"TabsAlert"> = () => {
};

export default TabsAlertActivity;

TabsAlertActivity.displayName = "TabsAlertActivity";
2 changes: 2 additions & 0 deletions component-docs/activities/TabsDisabledActivity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,5 @@ const TabsDisabledActivity: ActivityComponentType<"TabsDisabled"> = () => {
};

export default TabsDisabledActivity;

TabsDisabledActivity.displayName = "TabsDisabledActivity";
55 changes: 55 additions & 0 deletions component-docs/activities/skeleton/SkeletonWaveActivity.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import type { ActivityComponentType } from "@stackflow/react/future";
import * as React from "react";

import Layout from "@/activities/ActivityLayout";
import { Skeleton } from "@/seed-design/ui/skeleton";
import {
useSkeletonDuration,
useSkeletonLoading,
useSkeletonTimingFunction,
} from "@/stores/skeleton";

declare module "@stackflow/config" {
interface Register {
SkeletonWave: unknown;
}
}

const Fallback = () => {
return (
<div style={{ display: "flex", flexDirection: "column", gap: "12px" }}>
<Skeleton width="100%" height="300px" borderRadius="square" />
<div style={{ display: "flex", flexDirection: "column", gap: "4px" }}>
<Skeleton width="50px" height="50px" borderRadius="circle" />
<Skeleton width="100%" height="20px" borderRadius="rounded" />
<Skeleton width="200px" height="20px" borderRadius="rounded" />
</div>
</div>
);
};

const SkeletonWaveActivity: ActivityComponentType<"SkeletonWave"> = () => {
const isLoading = useSkeletonLoading();
const animationDuration = useSkeletonDuration();
const animationTiming = useSkeletonTimingFunction();

return (
<Layout>
<div
style={
{
padding: "16px",
"--skeleton-animation-duration": animationDuration,
"--skeleton-animation-timing-function": animationTiming,
} as React.CSSProperties
}
>
{isLoading ? <Fallback /> : <div>content</div>}
</div>
</Layout>
);
};

export default SkeletonWaveActivity;

SkeletonWaveActivity.displayName = "SkeletonWaveActivity";
49 changes: 0 additions & 49 deletions component-docs/assets/ImageProfileRating.tsx

This file was deleted.

13 changes: 13 additions & 0 deletions component-docs/components/ProgressCircleControls.css.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { style } from "@vanilla-extract/css";

export const controlBlock = style({
display: "flex",
gap: "8px",
});

export const controlLabel = style({});

export const controlInput = style({
flex: 1,
border: "1px solid #e5e5e5",
});
87 changes: 87 additions & 0 deletions component-docs/components/ProgressCircleControls.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import { BoxButton } from "@/seed-design/ui/box-button";
import {
useProgressCircleMaxValue,
useProgressCircleMinValue,
useProgressCircleDuration,
useProgressCircleEasing,
useProgressCircleValue,
useProgressCircleActions,
} from "@/stores/progress-circle";
import * as React from "react";

import * as css from "./ProgressCircleControls.css";

export const ProgressCircleControls = () => {
const [value, setValue] = React.useState(useProgressCircleValue());
const [maxValue, setMaxValue] = React.useState(useProgressCircleMaxValue());
const [minValue, setMinValue] = React.useState(useProgressCircleMinValue());
const [duration, setDuration] = React.useState(useProgressCircleDuration());
const [easing, setEasing] = React.useState(useProgressCircleEasing());

const { set } = useProgressCircleActions();

return (
<div>
<div className={css.controlBlock}>
<label className={css.controlLabel} htmlFor="value">
value
</label>
<input
className={css.controlInput}
id="value"
value={value}
onChange={(e) => setValue(Number(e.target.value))}
min={minValue}
max={maxValue}
/>
</div>
<div className={css.controlBlock}>
<label className={css.controlLabel} htmlFor="min-value">
Min Value
</label>
<input
className={css.controlInput}
id="min-value"
value={minValue}
onChange={(e) => setMinValue(Number(e.target.value))}
/>
</div>
<div className={css.controlBlock}>
<label className={css.controlLabel} htmlFor="max-value">
Max Value
</label>
<input
className={css.controlInput}
id="max-value"
value={maxValue}
onChange={(e) => setMaxValue(Number(e.target.value))}
/>
</div>
<div className={css.controlBlock}>
<label className={css.controlLabel} htmlFor="duration">
Duration
</label>
<input
className={css.controlInput}
id="duration"
value={duration}
onChange={(e) => setDuration(e.target.value)}
/>
</div>
<div className={css.controlBlock}>
<label className={css.controlLabel} htmlFor="easing">
Easing
</label>
<input
className={css.controlInput}
id="easing"
value={easing}
onChange={(e) => setEasing(e.target.value)}
/>
</div>
<BoxButton type="button" onClick={() => set({ value, minValue, maxValue, duration, easing })}>
적용
</BoxButton>
</div>
);
};
13 changes: 13 additions & 0 deletions component-docs/components/SkeletonControls.css.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { style } from "@vanilla-extract/css";

export const controlBlock = style({
display: "flex",
gap: "8px",
});

export const controlLabel = style({});

export const controlInput = style({
flex: 1,
border: "1px solid #e5e5e5",
});
64 changes: 64 additions & 0 deletions component-docs/components/SkeletonControls.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { BoxButton } from "@/seed-design/ui/box-button";
import {
useSkeletonActions,
useSkeletonDuration,
useSkeletonGradient,
useSkeletonLoading,
useSkeletonTimingFunction,
} from "@/stores/skeleton";
import * as React from "react";
import { controlBlock, controlInput, controlLabel } from "./SkeletonControls.css";

export const SkeletonControls = () => {
const isLoading = useSkeletonLoading();
const { toggleLoading, setControls } = useSkeletonActions();
const [duration, setDuration] = React.useState(useSkeletonDuration());
const [gradient, setGradient] = React.useState(useSkeletonGradient());
const [timingFunction, setTimingFunction] = React.useState(useSkeletonTimingFunction());

return (
<div>
<BoxButton variant={isLoading ? "neutralSolid" : "brandSolid"} onClick={toggleLoading}>
{isLoading ? "Stop Loading" : "Start Loading"}
</BoxButton>
<div>
<div className={controlBlock}>
<label className={controlLabel} htmlFor="duration">
Duration
</label>
<input
className={controlInput}
id="duration"
value={duration}
onChange={(e) => setDuration(e.target.value)}
/>
</div>
<div className={controlBlock}>
<label className={controlLabel} htmlFor="gradient">
Gradient
</label>
<input
className={controlInput}
id="gradient"
value={gradient}
onChange={(e) => setGradient(e.target.value)}
/>
</div>
<div className={controlBlock}>
<label className={controlLabel} htmlFor="timing-function">
Timing Function
</label>
<input
className={controlInput}
id="timing-function"
value={timingFunction}
onChange={(e) => setTimingFunction(e.target.value)}
/>
</div>
<BoxButton type="button" onClick={() => setControls({ duration, gradient })}>
적용
</BoxButton>
</div>
</div>
);
};
5 changes: 4 additions & 1 deletion component-docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@
"@stackflow/plugin-renderer-basic": "^1.1.11",
"@stackflow/react": "^1.2.1",
"@vanilla-extract/css": "^1.15.5",
"@vanilla-extract/recipes": "^0.5.5",
"next": "^14.2.5",
"nextra": "^2.13.4",
"nextra-theme-docs": "^2.13.4",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"simple-reveal": "^0.8.0",
"ts-morph": "^23.0.0"
"ts-morph": "^23.0.0",
"zustand": "^4.5.5"
},
"devDependencies": {
"@seed-design/cli": "workspace:^",
Expand All @@ -38,6 +40,7 @@
"autoprefixer": "^10.4.20",
"chalk": "^5.3.0",
"ts-node": "^10.9.2",
"ts-pattern": "^5.3.1",
"tslib": "^2.6.3",
"typescript": "^5.5.4",
"zod": "^3.23.8"
Expand Down
5 changes: 4 additions & 1 deletion component-docs/pages/_meta.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"index": "Introduction",
"get-started": "Get Started"
"get-started": "Get Started",
"components": "Components",
"patterns": "Patterns",
"libraries": "Libraries"
}
1 change: 1 addition & 0 deletions component-docs/pages/components/_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"alert-dialog": "AlertDialog",
"box-button": "BoxButton",
"checkbox": "Checkbox",
"progress-circle": "ProgressCircle",
"tabs": "Tabs"
}
4 changes: 2 additions & 2 deletions component-docs/pages/components/alert-dialog.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Preview } from '@/components/Preview';
import { Stackflow } from "@/components/Stackflow";

import registry from '@/public/registry/components/alert-dialog.json';
import AlertDialogActivity from "@/activities/AlertDialogActivity";
import AlertDialogDefaultActivity from "@/activities/AlertDialogDefaultActivity";

# Alert Dialog

Expand Down Expand Up @@ -46,4 +46,4 @@ export const AlertDialog: React.FC = () => {

### 예시

<Stackflow Activity={AlertDialogActivity} />
<Stackflow Activity={AlertDialogDefaultActivity} />
Loading
Loading