diff --git a/src/components/atoms/SkeletonBox/SkeletonBox.style.tsx b/src/components/atoms/SkeletonBox/SkeletonBox.style.tsx index 3dc53b85..fe9874f7 100644 --- a/src/components/atoms/SkeletonBox/SkeletonBox.style.tsx +++ b/src/components/atoms/SkeletonBox/SkeletonBox.style.tsx @@ -1,4 +1,4 @@ -import { styled, keyframes } from 'styled-components'; +import { styled, keyframes, css } from 'styled-components'; import { TTheme } from '@/types/TTheme'; import { TStyledPrefixAndPicker } from '@/types/TStyledPrefixAndPicker'; @@ -6,6 +6,21 @@ import { globalElementsizes } from '@/design/theme/globalSizes'; import { TSkeletonBox } from './TSkeleton.model'; import { clampLayer } from '@/utils/functions/clampLayer'; +type TSyledSkeletonBox = TStyledPrefixAndPicker; +export const StyledSkeletonBox = styled.div` + width: ${({ $sizeW }) => $sizeW && ($sizeW === 'fit' ? '100%' : globalElementsizes[$sizeW])}; + height: ${({ $sizeH }) => $sizeH && ($sizeH === 'fit' ? '100%' : globalElementsizes[$sizeH])}; + background-color: ${({ theme, $themeType = 'primary', $layer }) => theme.colors[$themeType][$layer || 0]}; + animation: ${({ theme, $themeType, $layer }) => createLoadingKeyframes({ theme, $themeType, $layer })} 2s infinite; + border-radius: ${({ theme, $borderRadius }) => theme.borderRadius[$borderRadius ?? 'xs'] || '0px'}; + ${({ $aspectRatio }) => + $aspectRatio && + css` + aspect-ratio: ${$aspectRatio}; + `} + ${({ $externalStyle }) => $externalStyle}; +`; + type TLoadingProps = TStyledPrefixAndPicker; const createLoadingKeyframes = ({ $themeType = 'primary', @@ -22,13 +37,3 @@ const createLoadingKeyframes = ({ background-color: ${theme.colors[$themeType][$layer ?? 0]}; } `; - -type TSyledSkeletonBox = TStyledPrefixAndPicker; -export const StyledSkeletonBox = styled.div` - width: ${({ $sizeW }) => ($sizeW === 'fit' ? '100%' : globalElementsizes[$sizeW || 'md'])}; - height: ${({ $sizeH }) => ($sizeH === 'fit' ? '100%' : globalElementsizes[$sizeH || 'md'])}; - background-color: ${({ theme, $themeType = 'primary', $layer }) => theme.colors[$themeType][$layer || 0]}; - animation: ${({ theme, $themeType, $layer }) => createLoadingKeyframes({ theme, $themeType, $layer })} 2s infinite; - border-radius: ${({ theme, $borderRadius }) => theme.borderRadius[$borderRadius ?? 'xs'] || '0px'}; - ${({ $externalStyle }) => $externalStyle}; -`; diff --git a/src/components/atoms/SkeletonBox/SkeletonBox.tsx b/src/components/atoms/SkeletonBox/SkeletonBox.tsx index 24e28781..c616a718 100644 --- a/src/components/atoms/SkeletonBox/SkeletonBox.tsx +++ b/src/components/atoms/SkeletonBox/SkeletonBox.tsx @@ -6,8 +6,8 @@ export default function SkeletonBox(props: TSkeletonBoxWithHTMLAttrs) { const { themeType = 'primary', layer = 0, - sizeH, - sizeW, + sizeH = 'fit', + sizeW = 'fit', aspectRatio, borderRadius, externalStyle, diff --git a/src/components/atoms/SkeletonBox/docu/SkeletonBox.stories.tsx b/src/components/atoms/SkeletonBox/docu/SkeletonBox.stories.tsx index bc7e7cf0..4d03025c 100644 --- a/src/components/atoms/SkeletonBox/docu/SkeletonBox.stories.tsx +++ b/src/components/atoms/SkeletonBox/docu/SkeletonBox.stories.tsx @@ -32,7 +32,7 @@ const meta = { type: 'select', }, table: { - defaultValue: { summary: 'md' }, + defaultValue: { summary: 'fit' }, }, }, sizeW: { @@ -42,7 +42,7 @@ const meta = { type: 'select', }, table: { - defaultValue: { summary: 'md' }, + defaultValue: { summary: 'fit' }, }, }, borderRadius: {