Skip to content

Commit

Permalink
Merge pull request #290 from TobiTRy/update--FancyGrid-for-better-usage
Browse files Browse the repository at this point in the history
Update  fancy grid for better usage
  • Loading branch information
TobiTRy authored May 12, 2024
2 parents 80445f0 + dd17cec commit 0e58093
Show file tree
Hide file tree
Showing 104 changed files with 492 additions and 256 deletions.
4 changes: 3 additions & 1 deletion lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export * from '@/components/atoms/RawLI';
export * from '@/components/atoms/RawUL';
export * from '@/components/atoms/RawA';
export * from '@/components/atoms/RawNav';
export * from '@/components/atoms/SpacingContainer';
export * from '@/components/atoms/FancySpacingBox';
export * from '@/components/atoms/DateInput';
export * from '@/components/atoms/SystemMessage';
export * from '@/components/atoms/NumberInput';
Expand All @@ -58,6 +58,7 @@ export * from '@/components/atoms/TextInput';
export * from '@/components/atoms/SkeletonBox';
export * from '@/components/atoms/TextGradient';
export * from '@/components/atoms/TitleForComponent';
export * from '@/components/atoms/ColoredText';

// ---------- Molecules ------- //
export * from '@/components/molecules/DateNumberWithStatus';
Expand Down Expand Up @@ -131,6 +132,7 @@ export * from '@/components/templates/FancyInfoCard';
export * from '@/components/templates/FancyDateDropDown';
export * from '@/components/templates/FancyMenuItem';
export * from '@/components/templates/FancyGrid';
export * from '@/components/templates/FancyGridItem';
export * from '@/components/templates/FancyRadioList';
export * from '@/components/templates/FancyFlexBox';
export * from '@/components/templates/FancyHandyNav';
Expand Down
2 changes: 1 addition & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const OwnUl = styled.ul<{ theme: TTheme }>`
li {
a {
color: ${({ theme }) => theme.colors.secondary[0]};
color: ${({ theme }) => theme.color.secondary[0]};
text-decoration: none;
}
}
Expand Down
28 changes: 14 additions & 14 deletions src/Routes/ColorGeneratorRoute/ColorGeneratorRoute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import { TTheme } from '@/types/TTheme';
export default function ColorGeneratorRoute() {
const theme = themeStore((state) => state.theme);
//get keys of primary
const primaryKeys = Object?.keys(theme?.colors.primary);
const accentKeys = Object?.keys(theme?.colors.accent);
const secondaryKeys = Object?.keys(theme?.colors.secondary);
const infoKeys = Object?.keys(theme?.colors.info);
const warningKeys = Object?.keys(theme?.colors.warning);
const errorKeys = Object?.keys(theme?.colors.error);
const successKeys = Object?.keys(theme?.colors.success);
const primaryKeys = Object?.keys(theme?.color.primary);
const accentKeys = Object?.keys(theme?.color.accent);
const secondaryKeys = Object?.keys(theme?.color.secondary);
const infoKeys = Object?.keys(theme?.color.info);
const warningKeys = Object?.keys(theme?.color.warning);
const errorKeys = Object?.keys(theme?.color.error);
const successKeys = Object?.keys(theme?.color.success);

return (
<div style={{ display: 'flex' }}>
Expand All @@ -24,7 +24,7 @@ export default function ColorGeneratorRoute() {
return (
<div
key={index}
style={{ width: '100px', height: '100px', backgroundColor: theme.colors.primary[color] }}
style={{ width: '100px', height: '100px', backgroundColor: theme.color.primary[color] }}
></div>
);
})}
Expand All @@ -34,7 +34,7 @@ export default function ColorGeneratorRoute() {
return (
<div
key={index}
style={{ width: '100px', height: '100px', backgroundColor: theme.colors.accent[color] }}
style={{ width: '100px', height: '100px', backgroundColor: theme.color.accent[color] }}
></div>
);
})}
Expand All @@ -44,7 +44,7 @@ export default function ColorGeneratorRoute() {
return (
<div
key={index}
style={{ width: '100px', height: '100px', backgroundColor: theme.colors.accent[color] }}
style={{ width: '100px', height: '100px', backgroundColor: theme.color.accent[color] }}
></div>
);
})}
Expand All @@ -55,7 +55,7 @@ export default function ColorGeneratorRoute() {
return (
<div
key={index}
style={{ width: '100px', height: '100px', backgroundColor: theme.colors.secondary[color] }}
style={{ width: '100px', height: '100px', backgroundColor: theme.color.secondary[color] }}
></div>
);
})}
Expand All @@ -65,7 +65,7 @@ export default function ColorGeneratorRoute() {
return (
<div
key={index}
style={{ width: '100px', height: '100px', backgroundColor: theme.colors.warning[color] }}
style={{ width: '100px', height: '100px', backgroundColor: theme.color.warning[color] }}
></div>
);
})}
Expand All @@ -75,7 +75,7 @@ export default function ColorGeneratorRoute() {
return (
<div
key={index}
style={{ width: '100px', height: '100px', backgroundColor: theme.colors.error[color] }}
style={{ width: '100px', height: '100px', backgroundColor: theme.color.error[color] }}
></div>
);
})}
Expand All @@ -85,7 +85,7 @@ export default function ColorGeneratorRoute() {
return (
<div
key={index}
style={{ width: '100px', height: '100px', backgroundColor: theme.colors.success[color] }}
style={{ width: '100px', height: '100px', backgroundColor: theme.color.success[color] }}
></div>
);
})}
Expand Down
2 changes: 1 addition & 1 deletion src/Routes/DesignWrapper/Wrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const Area = styled.div<{ $style: CSSProp; theme: TTheme }>`
width: 90%;
display: flex;
flex-direction: column;
color: ${({ theme }) => theme.colors.secondary[0]};
color: ${({ theme }) => theme.color.secondary[0]};
& > h1 {
text-align: center;
Expand Down
1 change: 1 addition & 0 deletions src/Routes/InfoCardRoute/InfoCardRoute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export default function InfoCardRoute() {
</FancyBox>
<FancyInfoCard
outlined
icon={<SVGCheckMark />}
sizeC="sm"
themeType="info"
title="A Vergy good title"
Expand Down
2 changes: 1 addition & 1 deletion src/Routes/TextGradientRoute/TextGradientRoute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { themeStore } from '@/design/theme/themeStore';
import { Typography } from '@/components/atoms/Typography';
import { TGradientColor } from '@/components/atoms/TextGradient/TTextGradient.model';

const themeColors = themeStore.getState().theme.colors;
const themeColors = themeStore.getState().theme.color;

const colorsArray: TGradientColor[] = [
{
Expand Down
6 changes: 3 additions & 3 deletions src/components/atoms/AvilableDot/AvailableDot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ const AvailableDot = styled.div<{ $available?: IAvailableDot; theme?: TTheme }>`
background-color: ${({ $available = 'completly', theme }) => {
switch ($available) {
case 'completly':
return theme.colors.success[0];
return theme.color.success[0];
case 'partially':
return theme.colors.warning[0];
return theme.color.warning[0];
case 'not':
return theme.colors.error[0];
return theme.color.error[0];
case 'transparent':
return 'transparent';
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/atoms/ColorIndicator/ColorIndicator.style.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ export const Indicator = styled.div.attrs<{ $color: string; theme: TTheme }>(({
},
}))<{ $isActive: boolean }>`
border-radius: 50% 50% 50% 0;
border: 1.5px solid ${({ theme }) => theme.colors.secondary[0]};
background-color: ${({ theme }) => theme.colors.secondary[0]};
border: 1.5px solid ${({ theme }) => theme.color.secondary[0]};
background-color: ${({ theme }) => theme.color.secondary[0]};
${boxShadow.sm};
position: absolute;
top: ${({ $isActive }) => ($isActive ? '-105px' : '-5px')};
Expand Down
23 changes: 23 additions & 0 deletions src/components/atoms/ColoredText/ColoredText.style.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { styled } from 'styled-components';
import { TStyledPrefixAndPicker } from '@/types/TStyledPrefixAndPicker';

import { TColoredText } from './TColoredText.model';
import { TTheme } from '@/types/TTheme';
import { getBackgroundColor } from '@/design/designFunctions/colorCalculatorForComponent';
import { simpleColorTransition } from '@/design/designFunctions/simpleColorTransition';

type TStyledItem = TStyledPrefixAndPicker<TColoredText, 'layer' | 'themeType' | 'hoverLayer' | 'externalStyle'>;
export const StyledItem = styled.span<TStyledItem & { theme: TTheme }>`
* {
color: ${({ theme, $themeType = 'secondary', $layer = 0 }) => getBackgroundColor({ theme, $themeType, $layer })};
&:hover {
color: ${({ theme, $themeType = 'secondary', $hoverLayer = 2 }) =>
getBackgroundColor({ theme, $themeType, $layer: $hoverLayer })};
}
${simpleColorTransition}
${({ $externalStyle }) => $externalStyle}
}
`;
14 changes: 14 additions & 0 deletions src/components/atoms/ColoredText/ColoredText.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { TDynamicElement } from '@/types/TDynamicElement';
import { StyledItem } from './ColoredText.style';
import { TColoredText } from './TColoredText.model';
import { ElementType } from 'react';

export default function ColoredText<T extends ElementType>(props: TColoredText & TDynamicElement<T>) {
const { as, children, themeType, layer, externalStyle } = props;

return (
<StyledItem as={as} $themeType={themeType} $layer={layer} $externalStyle={externalStyle}>
{children}
</StyledItem>
);
}
11 changes: 11 additions & 0 deletions src/components/atoms/ColoredText/TColoredText.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { TLayer } from '@/types/TLayer';
import { TUiColorTypes } from '@/types/TUiColorTypes';
import { CSSProp } from 'styled-components';

export type TColoredText = {
children?: React.ReactNode;
themeType?: TUiColorTypes;
layer?: TLayer;
hoverLayer?: TLayer;
externalStyle?: CSSProp;
};
73 changes: 73 additions & 0 deletions src/components/atoms/ColoredText/docu/ColoredText.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// Import necessary dependencies
import { Meta, StoryObj } from '@storybook/react';

// Import the component to be tested
import ColoredText from '../ColoredText';
import templateThemeType from '@/stories/templateSettingsForStorys/templatesForThemeType';
// Define metadata for the story
const meta = {
title: 'components/atoms/ColoredText',
component: ColoredText,
parameters: {
docs: {
description: {
component: ' A component that displays text with a color based on the themeType and layer properties.',
},
},
},

// Define arguments for the story
argTypes: {
hoverLayer: {
description: 'The active state of the color indicator',
control: {
type: 'range',
min: 0,
max: 9,
step: 1,
},
table: {
defaultValue: { summary: 2 },
},
},
...templateThemeType('allThemeTypes', 'secondary', 0),
externalStyle: {
description: 'External style for the component',
control: {
type: 'object',
},
},
as: {
description: 'The element type to render (all types)',
control: {
type: 'select',
options: ['span', 'div', 'p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'],
},
table: {
defaultValue: { summary: 'span' },
},
},
},

// Add tags to the story
tags: ['autodocs'],
} satisfies Meta<typeof ColoredText>;

// Export the metadata
export default meta;
// Define the story object
type Story = StoryObj<typeof meta>;

// Define the primary story
export const Primary: Story = {
render: (args) => (
<ColoredText {...args}>
<span>Moooiin</span>
</ColoredText>
),
args: {
themeType: 'primary',
layer: 0,
as: 'span',
},
};
2 changes: 2 additions & 0 deletions src/components/atoms/ColoredText/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { default as ColoredText } from './ColoredText';
export type { TColoredText } from './TColoredText.model';
18 changes: 9 additions & 9 deletions src/components/atoms/DateNumberAtom/DateNumberAtom.style.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ export const StyledDay = styled.button<IStyledDay & { theme: TTheme }>`
align-items: center;
border-radius: ${({ theme }) => theme.borderRadius.complete};
color: ${({ $isCurrentDay, theme, $themeType = 'secondary', $layer }) =>
$isCurrentDay ? theme.colors.accent[0] : getTextColor({ $themeType, $textLayer: $layer, theme })};
border: ${({ $selected, theme }) => ($selected ? `1px solid ${theme.colors.accent[0]}` : `none`)};
$isCurrentDay ? theme.color.accent[0] : getTextColor({ $themeType, $textLayer: $layer, theme })};
border: ${({ $selected, theme }) => ($selected ? `1px solid ${theme.color.accent[0]}` : `none`)};
background-color: transparent;
padding: 0;
min-height: 24px;
Expand All @@ -47,30 +47,30 @@ export const StyledDay = styled.button<IStyledDay & { theme: TTheme }>`
&:hover,
&:active {
border: 1px solid ${({ theme }) => theme.colors.accent[0]};
border: 1px solid ${({ theme }) => theme.color.accent[0]};
}
${({ $range, theme }) =>
$range?.start &&
css`
border-radius: 40% 5px 5px 40%;
background-color: ${theme.colors.accent[0]};
color: ${theme.colors.secondary[0]};
background-color: ${theme.color.accent[0]};
color: ${theme.color.secondary[0]};
`}
${({ $range, theme }) =>
$range?.inRange &&
css`
background-color: ${theme.colors.accent[0]};
color: ${theme.colors.secondary[0]};
background-color: ${theme.color.accent[0]};
color: ${theme.color.secondary[0]};
`}
${({ $range, theme }) =>
$range?.end &&
css`
border-radius: 5px 40% 40% 5px;
background-color: ${theme.colors.accent[0]};
color: ${theme.colors.secondary[0]};
background-color: ${theme.color.accent[0]};
color: ${theme.color.secondary[0]};
`}
&:disabled {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useState } from 'react';

import { Typography } from '@/components/atoms/Typography';
import { RawButton } from '@/components/atoms/RawButton';
import { SpacingsContainer } from '@/components/atoms/SpacingContainer';
import { FancySpacingBox } from '@/components/atoms/FancySpacingBox';
import { TDescriptionPreview } from '@/components/atoms/DescriptionPreview/DescriptionPreview.model';

export default function DescriptionPreview(props: TDescriptionPreview) {
Expand All @@ -14,7 +14,7 @@ export default function DescriptionPreview(props: TDescriptionPreview) {
return (
<>
{description.length < letterLimit || isShowMore ? description : preview}
<SpacingsContainer as={'span'} margin={['xxs', 0, 0, 0]}>
<FancySpacingBox as={'span'} margin={['xxs', 0, 0, 0]}>
{description.length > letterLimit && (
<RawButton onClick={() => setIsShowMore((prev) => !prev)}>
<Typography
Expand All @@ -27,7 +27,7 @@ export default function DescriptionPreview(props: TDescriptionPreview) {
</Typography>
</RawButton>
)}
</SpacingsContainer>
</FancySpacingBox>
</>
);
}
Loading

0 comments on commit 0e58093

Please sign in to comment.