-
-
Notifications
You must be signed in to change notification settings - Fork 302
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add skeleton components * fix * fix * fix skeleton * fix * add custom * fix skeleton
- Loading branch information
Showing
8 changed files
with
169 additions
and
6 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import React from 'react' | ||
import { Box, Skeleton, SkeletonCircle, SkeletonText } from '@chakra-ui/react' | ||
import ComponentPreview from '~components/editor/ComponentPreview' | ||
import { useDropComponent } from '~hooks/useDropComponent' | ||
import { useInteractive } from '~hooks/useInteractive' | ||
|
||
const SkeletonPreview: React.FC<{ component: IComponent }> = ({ | ||
component, | ||
}) => { | ||
const { drop, isOver } = useDropComponent(component.id) | ||
const { props, ref } = useInteractive(component, true, true) | ||
|
||
if (isOver) { | ||
props.bg = 'teal.50' | ||
} | ||
|
||
return ( | ||
<Box ref={drop(ref)} {...props} m={0}> | ||
<Skeleton {...component.props}> | ||
{component.children.map((key: string) => ( | ||
<ComponentPreview key={key} componentName={key} /> | ||
))} | ||
</Skeleton> | ||
</Box> | ||
) | ||
} | ||
|
||
export const SkeletonTextPreview = ({ component }: IPreviewProps) => { | ||
const { props, ref } = useInteractive(component, true) | ||
const { drop, isOver } = useDropComponent(component.id) | ||
|
||
let boxProps: any = {} | ||
|
||
if (isOver) { | ||
props.bg = 'teal.50' | ||
} | ||
|
||
return ( | ||
<Box ref={drop(ref)} {...boxProps}> | ||
<SkeletonText {...props}> | ||
{component.children.map((key: string) => ( | ||
<ComponentPreview key={key} componentName={key} /> | ||
))} | ||
</SkeletonText> | ||
</Box> | ||
) | ||
} | ||
|
||
export const SkeletonCirclePreview = ({ component }: IPreviewProps) => { | ||
const { props, ref } = useInteractive(component, true, true) | ||
const { drop, isOver } = useDropComponent(component.id) | ||
|
||
if (isOver) { | ||
props.bg = 'teal.50' | ||
} | ||
|
||
return ( | ||
<Box display="inline-block" ref={drop(ref)} {...props}> | ||
<SkeletonCircle {...component.props}> | ||
{component.children.map((key: string) => ( | ||
<ComponentPreview key={key} componentName={key} /> | ||
))} | ||
</SkeletonCircle> | ||
</Box> | ||
) | ||
} | ||
|
||
export default SkeletonPreview |
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
50 changes: 50 additions & 0 deletions
50
src/components/inspector/panels/components/SkeletonPanel.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,50 @@ | ||
import { memo } from 'react' | ||
import ColorPickerControl from '~components/inspector/controls/ColorPickerControl' | ||
import ColorsControl from '~components/inspector/controls/ColorsControl' | ||
import SwitchControl from '~components/inspector/controls/SwitchControl' | ||
import TextControl from '~components/inspector/controls/TextControl' | ||
import usePropsSelector from '~hooks/usePropsSelector' | ||
|
||
interface SkeletonPanelProps { | ||
isSkeletonText?: boolean | ||
isSkeletonCircle?: boolean | ||
} | ||
|
||
const SkeletonPanel = ({ | ||
isSkeletonText, | ||
isSkeletonCircle, | ||
}: SkeletonPanelProps) => { | ||
return ( | ||
<> | ||
<ColorsControl | ||
name="startColor" | ||
label="Start Color" | ||
enableHues | ||
withFullColor | ||
/> | ||
|
||
<ColorsControl | ||
name="endColor" | ||
label="End Color" | ||
enableHues | ||
withFullColor | ||
/> | ||
|
||
<SwitchControl label="Is Loaded" name="isLoaded" /> | ||
|
||
<TextControl name="fadeDuration" label="Fade duration" /> | ||
<TextControl name="speed" label="Speed" /> | ||
|
||
{isSkeletonText && ( | ||
<> | ||
<TextControl name="noOfLines" label="No of lines" /> | ||
<TextControl name="spacing" label="Spacing" /> | ||
</> | ||
)} | ||
|
||
{isSkeletonCircle && <TextControl name="size" label="Size" />} | ||
</> | ||
) | ||
} | ||
|
||
export default memo(SkeletonPanel) |
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
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
80b9ec6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
openchakra – ./
openchakra-wine.vercel.app
openchakra-git-master-premieroctet.vercel.app
openchakra-premieroctet.vercel.app