-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
162ed28
commit cbe226c
Showing
13 changed files
with
498 additions
and
259 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file added
BIN
+19.8 KB
.yarn/cache/use-sync-external-store-npm-1.2.2-7923c915e1-fe07c071c4.zip
Binary file not shown.
Binary file not shown.
46 changes: 46 additions & 0 deletions
46
component-docs/activities/skeleton/SkeletonPulseActivitiy.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import type { ActivityComponentType } from "@stackflow/react/future"; | ||
import * as React from "react"; | ||
|
||
import Layout from "@/activities/ActivityLayout"; | ||
import { useSkeletonLoading } from "@/stores/skeleton"; | ||
import { Skeleton } from "@/seed-design/ui/skeleton"; | ||
|
||
declare module "@stackflow/config" { | ||
interface Register { | ||
SkeletonPulse: unknown; | ||
} | ||
} | ||
|
||
const InfiniteLoader = () => { | ||
throw new Promise(() => {}); | ||
}; | ||
|
||
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 SkeletonPulseActivitiy: ActivityComponentType<"SkeletonPulse"> = () => { | ||
const isLoading = useSkeletonLoading(); | ||
|
||
return ( | ||
<Layout> | ||
<div style={{ padding: "16px" }}> | ||
<React.Suspense fallback={<Fallback />}> | ||
<div>content</div> | ||
{isLoading && <InfiniteLoader />} | ||
</React.Suspense> | ||
</div> | ||
</Layout> | ||
); | ||
}; | ||
|
||
export default SkeletonPulseActivitiy; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { BoxButton } from "@/seed-design/ui/box-button"; | ||
import { useSkeletonActions, useSkeletonLoading } from "@/stores/skeleton"; | ||
import * as React from "react"; | ||
|
||
export const LoadingTrigger = () => { | ||
const isLoading = useSkeletonLoading(); | ||
const { toggleLoading } = useSkeletonActions(); | ||
return ( | ||
<BoxButton | ||
style={{ | ||
position: "sticky", | ||
bottom: "20px", | ||
zIndex: 1000, | ||
}} | ||
variant={isLoading ? "neutral" : "brand"} | ||
onClick={toggleLoading} | ||
> | ||
{isLoading ? "Stop Loading" : "Start Loading"} | ||
</BoxButton> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Stackflow } from "@/components/Stackflow"; | ||
import { LoadingTrigger } from '@/components/LoadingTrigger'; | ||
import SkeletonPulseActivity from "@/activities/skeleton/SkeletonPulseActivitiy"; | ||
|
||
# Skeleton | ||
|
||
### Pulse | ||
|
||
<Stackflow Activity={SkeletonPulseActivity} /> | ||
|
||
<LoadingTrigger /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { keyframes } from "@vanilla-extract/css"; | ||
import { recipe } from "@vanilla-extract/recipes"; | ||
|
||
// #F7F8F9 | ||
// #F7F8F950 | ||
const pulse = keyframes({ | ||
"0%": { | ||
backgroundPositionX: "100%", | ||
}, | ||
|
||
"50%": { | ||
backgroundPositionX: "100%", | ||
}, | ||
|
||
"100%": { | ||
backgroundPositionX: "-100%", | ||
}, | ||
}); | ||
|
||
export const skeleton = recipe({ | ||
base: {}, | ||
|
||
variants: { | ||
type: { | ||
pulse: { | ||
backgroundImage: "linear-gradient(90deg, #F7F8F9 0%, #F7F8F950 20%, #F7F8F9 40%)", | ||
backgroundSize: "200% 100%", | ||
animationFillMode: "forwards", | ||
|
||
animationName: pulse, | ||
animationDuration: "1s", | ||
animationTimingFunction: "ease-in-out", | ||
animationIterationCount: "infinite", | ||
}, | ||
}, | ||
|
||
borderRadius: { | ||
circle: { | ||
borderRadius: "50%", | ||
}, | ||
rounded: { | ||
borderRadius: "4px", | ||
}, | ||
square: { | ||
borderRadius: "0px", | ||
}, | ||
}, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
"use client"; | ||
|
||
import * as React from "react"; | ||
|
||
import * as css from "./skeleton.css"; | ||
|
||
interface SkeletonProps { | ||
width: number | string; | ||
height: number | string; | ||
borderRadius: "circle" | "rounded" | "square"; | ||
type?: "pulse"; | ||
} | ||
|
||
// TODO: Spec | ||
// TODO: Recipe | ||
export const Skeleton = React.forwardRef<HTMLDivElement, SkeletonProps>((props, ref) => { | ||
const { width, height, borderRadius, type = "pulse" } = props; | ||
return ( | ||
<div | ||
ref={ref} | ||
style={{ | ||
width, | ||
height, | ||
}} | ||
className={css.skeleton({ type, borderRadius })} | ||
/> | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { create } from "zustand"; | ||
|
||
interface SkeletonState { | ||
isLoading: boolean; | ||
actions: { | ||
toggleLoading: () => void; | ||
}; | ||
} | ||
|
||
const useSkeleton = create<SkeletonState>((set) => ({ | ||
isLoading: true, | ||
actions: { | ||
toggleLoading: () => set((state) => ({ isLoading: !state.isLoading })), | ||
}, | ||
})); | ||
|
||
export const useSkeletonLoading = () => useSkeleton((state) => state.isLoading); | ||
export const useSkeletonActions = () => useSkeleton((state) => state.actions); |
Oops, something went wrong.