-
Notifications
You must be signed in to change notification settings - Fork 415
Feat/doc editor skeleton #1491
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
Open
Ovgodd
wants to merge
1
commit into
main
Choose a base branch
from
feat/doc-editor-skeleton
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Feat/doc editor skeleton #1491
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
38 changes: 34 additions & 4 deletions
38
src/frontend/apps/impress/src/features/left-panel/components/LeftPanelHeaderButton.tsx
This file contains hidden or 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
153 changes: 153 additions & 0 deletions
153
src/frontend/apps/impress/src/features/skeletons/components/DocEditorSkeleton.tsx
This file contains hidden or 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,153 @@ | ||
import { css, keyframes } from 'styled-components'; | ||
|
||
import { Box, BoxType } from '@/components'; | ||
import { useCunninghamTheme } from '@/cunningham'; | ||
import { useResponsiveStore } from '@/stores'; | ||
|
||
const shimmer = keyframes` | ||
0% { | ||
background-position: -1000px 0; | ||
} | ||
100% { | ||
background-position: 1000px 0; | ||
} | ||
`; | ||
|
||
type SkeletonLineProps = Partial<BoxType>; | ||
|
||
type SkeletonCircleProps = Partial<BoxType>; | ||
|
||
export const DocEditorSkeleton = () => { | ||
const { isDesktop } = useResponsiveStore(); | ||
const { spacingsTokens, colorsTokens } = useCunninghamTheme(); | ||
|
||
const SkeletonLine = ({ $css, ...props }: SkeletonLineProps) => { | ||
return ( | ||
<Box | ||
$width="100%" | ||
$height="16px" | ||
$css={css` | ||
background: linear-gradient( | ||
90deg, | ||
${colorsTokens['greyscale-100']} 0%, | ||
${colorsTokens['greyscale-200']} 50%, | ||
${colorsTokens['greyscale-100']} 100% | ||
); | ||
background-size: 1000px 100%; | ||
animation: ${shimmer} 2s infinite linear; | ||
border-radius: 4px; | ||
${$css} | ||
`} | ||
{...props} | ||
/> | ||
); | ||
}; | ||
|
||
const SkeletonCircle = ({ $css, ...props }: SkeletonCircleProps) => { | ||
return ( | ||
<Box | ||
$width="32px" | ||
$height="32px" | ||
$css={css` | ||
background: linear-gradient( | ||
90deg, | ||
${colorsTokens['greyscale-100']} 0%, | ||
${colorsTokens['greyscale-200']} 50%, | ||
${colorsTokens['greyscale-100']} 100% | ||
); | ||
background-size: 1000px 100%; | ||
animation: ${shimmer} 2s infinite linear; | ||
border-radius: 50%; | ||
${$css} | ||
`} | ||
{...props} | ||
/> | ||
); | ||
}; | ||
|
||
return ( | ||
<> | ||
{/* Main Editor Container */} | ||
<Box | ||
$maxWidth="868px" | ||
$width="100%" | ||
$height="100%" | ||
className="--docs--doc-editor-skeleton" | ||
> | ||
{/* Header Skeleton */} | ||
<Box | ||
$padding={{ horizontal: isDesktop ? '70px' : 'base' }} | ||
className="--docs--doc-editor-header-skeleton" | ||
> | ||
<Box | ||
$width="100%" | ||
$padding={{ top: isDesktop ? '65px' : 'md' }} | ||
$gap={spacingsTokens['base']} | ||
> | ||
<Box | ||
$direction="row" | ||
$align="center" | ||
$width="100%" | ||
$padding={{ bottom: 'xs' }} | ||
> | ||
<Box | ||
$direction="row" | ||
$justify="space-between" | ||
$css="flex:1;" | ||
$gap="0.5rem 1rem" | ||
$align="center" | ||
$maxWidth="100%" | ||
> | ||
{/* Title and metadata skeleton */} | ||
<Box $gap="0.25rem" $css="flex:1;"> | ||
{/* Title - "Document sans titre" style */} | ||
<SkeletonLine $width="35%" $height="40px" /> | ||
|
||
{/* Metadata (role and last update) */} | ||
<Box $direction="row" $gap="0.5rem" $align="center"> | ||
<SkeletonLine $maxWidth="260px" $height="12px" /> | ||
</Box> | ||
</Box> | ||
|
||
{/* Toolbox skeleton (buttons) */} | ||
<Box $direction="row" $gap="0.75rem" $align="center"> | ||
{/* Partager button */} | ||
<SkeletonLine $width="90px" $height="40px" /> | ||
{/* Download icon */} | ||
<SkeletonCircle $width="40px" $height="40px" /> | ||
{/* Menu icon */} | ||
<SkeletonCircle $width="40px" $height="40px" /> | ||
</Box> | ||
</Box> | ||
</Box> | ||
|
||
{/* Separator */} | ||
<SkeletonLine $height="1px" /> | ||
</Box> | ||
</Box> | ||
|
||
{/* Content Skeleton */} | ||
<Box | ||
$direction="row" | ||
$width="100%" | ||
$css="overflow-x: clip; flex: 1;" | ||
$position="relative" | ||
className="--docs--doc-editor-content-skeleton" | ||
> | ||
<Box | ||
$css="flex:1;" | ||
$position="relative" | ||
$width="100%" | ||
$padding={{ horizontal: isDesktop ? '70px' : 'base', top: 'lg' }} | ||
> | ||
{/* Placeholder text similar to screenshot */} | ||
<Box $gap="0rem"> | ||
{/* Single placeholder line like in the screenshot */} | ||
<SkeletonLine $width="85%" $height="20px" /> | ||
</Box> | ||
</Box> | ||
</Box> | ||
</Box> | ||
</> | ||
); | ||
}; |
71 changes: 71 additions & 0 deletions
71
src/frontend/apps/impress/src/features/skeletons/components/Skeleton.tsx
This file contains hidden or 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,71 @@ | ||
import { PropsWithChildren, useEffect, useRef, useState } from 'react'; | ||
import { css, keyframes } from 'styled-components'; | ||
|
||
import { Box } from '@/components'; | ||
import { useCunninghamTheme } from '@/cunningham'; | ||
import { useSkeletonStore } from '@/features/skeletons'; | ||
|
||
const FADE_DURATION_MS = 250; | ||
|
||
const fadeOut = keyframes` | ||
from { | ||
opacity: 1; | ||
} | ||
to { | ||
opacity: 0; | ||
} | ||
`; | ||
|
||
export const Skeleton = ({ children }: PropsWithChildren) => { | ||
const { isSkeletonVisible } = useSkeletonStore(); | ||
const { colorsTokens } = useCunninghamTheme(); | ||
const [isVisible, setIsVisible] = useState(isSkeletonVisible); | ||
const [isFadingOut, setIsFadingOut] = useState(true); | ||
const timeoutVisibleRef = useRef<NodeJS.Timeout | null>(null); | ||
|
||
useEffect(() => { | ||
if (isSkeletonVisible) { | ||
setIsVisible(true); | ||
setIsFadingOut(false); | ||
} else { | ||
setIsFadingOut(true); | ||
if (!timeoutVisibleRef.current) { | ||
timeoutVisibleRef.current = setTimeout(() => { | ||
setIsVisible(false); | ||
}, FADE_DURATION_MS * 2); | ||
} | ||
} | ||
|
||
return () => { | ||
if (timeoutVisibleRef.current) { | ||
clearTimeout(timeoutVisibleRef.current); | ||
timeoutVisibleRef.current = null; | ||
} | ||
}; | ||
}, [isSkeletonVisible]); | ||
|
||
if (!isVisible) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<Box | ||
className="--docs--skeleton" | ||
$align="center" | ||
$width="100%" | ||
$height="100%" | ||
$background={colorsTokens['greyscale-000']} | ||
$css={css` | ||
position: absolute; | ||
inset: 0; | ||
z-index: 999; | ||
overflow: hidden; | ||
will-change: opacity; | ||
animation: ${isFadingOut && fadeOut} ${FADE_DURATION_MS}ms ease-in-out | ||
forwards; | ||
`} | ||
> | ||
{children} | ||
</Box> | ||
); | ||
}; |
2 changes: 2 additions & 0 deletions
2
src/frontend/apps/impress/src/features/skeletons/components/index.ts
This file contains hidden or 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,2 @@ | ||
export * from './DocEditorSkeleton'; | ||
export * from './Skeleton'; |
This file contains hidden or 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,2 @@ | ||
export * from './components'; | ||
export * from './store'; |
1 change: 1 addition & 0 deletions
1
src/frontend/apps/impress/src/features/skeletons/store/index.ts
This file contains hidden or 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 @@ | ||
export * from './useSkeletonStore'; |
12 changes: 12 additions & 0 deletions
12
src/frontend/apps/impress/src/features/skeletons/store/useSkeletonStore.tsx
This file contains hidden or 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,12 @@ | ||
import { create } from 'zustand'; | ||
|
||
interface SkeletonStore { | ||
isSkeletonVisible: boolean; | ||
setIsSkeletonVisible: (isSkeletonVisible: boolean) => void; | ||
} | ||
|
||
export const useSkeletonStore = create<SkeletonStore>((set) => ({ | ||
isSkeletonVisible: false, | ||
setIsSkeletonVisible: (isSkeletonVisible: boolean) => | ||
set({ isSkeletonVisible }), | ||
})); |
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.