Skip to content

Commit

Permalink
Merge pull request #305 from TobiTRy/303-update-to-fit-the-ux
Browse files Browse the repository at this point in the history
303 update to fit the ux
  • Loading branch information
TobiTRy authored Dec 17, 2024
2 parents 7b17f39 + 15fcd03 commit 7f44960
Show file tree
Hide file tree
Showing 103 changed files with 1,197 additions and 579 deletions.
1 change: 1 addition & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ module.exports = {
'@typescript-eslint/restrict-plus-operands': 'off',
'@typescript-eslint/no-non-null-asserted-optional-chain': 'off',
'@typescript-eslint/no-redundant-type-constituents': 'off',
'@typescript-eslint/no-unused-vars': 'warn',
'@typescript-eslint/ban-types': [
'error',
{
Expand Down
2 changes: 2 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
prefer-workspace-packages=true
legacy-peer-deps=true
1 change: 1 addition & 0 deletions lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ export * from '@/utils/functions/copyToClipBoard';
export * from '@/utils/functions/calcCSSValuesWithOffset';
export * from '@/utils/hooks/useActiveBreakpoint';
export * from '@/utils/hooks/useBreakpointComparison';
export * from '@/utils/hooks/useBodyOverflow';
export * from '@/utils/validations/isColorValid';

// ---------- Design ------- //
Expand Down
25 changes: 18 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"name": "TobiTRy"
},
"private": false,
"version": "0.5.7",
"version": "0.5.8",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down Expand Up @@ -48,11 +48,14 @@
"dependencies": {
"@types/react-router-dom": "5.3.3",
"@types/react-test-renderer": "^18.3.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-router-dom": "^6.23.0",
"rollup-preserve-directives": "^1.1.1",
"vite-plugin-dts": "^3.9.0"
},
"devDependencies": {
"@react-spring/web": "^9.7.3",
"@storybook/addon-essentials": "8.0.5",
"@storybook/addon-interactions": "8.0.5",
"@storybook/addon-links": "8.0.5",
Expand All @@ -67,12 +70,15 @@
"@swc/core": "^1.4.17",
"@testing-library/jest-dom": "^6.4.5",
"@testing-library/react": "^15.0.6",
"@types/react": "^18.3.1",
"@types/react-dom": "^18.3.0",
"@types/color": "^3.0.6",
"@types/jest": "^29.5.14",
"@types/mocha": "^10.0.10",
"@types/uuid": "^9.0.8",
"@typescript-eslint/eslint-plugin": "^7.2.0",
"@typescript-eslint/parser": "^7.2.0",
"@vitejs/plugin-react-swc": "^3.6.0",
"eslint": "^8.57.0",
"color": "^4.2.3",
"eslint": "8.57.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.6",
"eslint-plugin-storybook": "0.8.0",
Expand All @@ -82,15 +88,16 @@
"json": "11.0.0",
"lint-staged": "^15.2.2",
"prettier": "^3.2.5",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-test-renderer": "^18.3.1",
"rollup-plugin-visualizer": "^5.12.0",
"storybook": "8.0.5",
"storybook-dark-mode": "4.0.1",
"styled-components": "^6.1.8",
"typescript": "^5.0.2",
"uuid": "^9.0.1",
"vite": "^5.2.11",
"vitest": "^1.6.0"
"vitest": "2.1.5",
"zustand": "^4.5.2"
},
"peerDependencies": {
"@react-spring/web": "9.7.3",
Expand Down Expand Up @@ -142,5 +149,9 @@
},
"publishConfig": {
"registry": "https://registry.npmjs.org/"
},
"resolutions": {
"@types/react": "18.3.1",
"@types/react-dom": "18.3.1"
}
}
5 changes: 5 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import StepperRoute from '@/Routes/StepperRoute/StepperRoute';
import SwitchActiveIndicatorRoute from '@/Routes/SwitchActiveIndicatorRoute/SwitchActiveIndicatorRoute';
import TextGradientRoute from '@/Routes/TextGradientRoute/TextGradientRoute';
import { useFancyModalStore } from './Routes/ModalRoute/ModalRoute';
import MaterialColorGeneratorRoute from '@/Routes/MaterialColorGeneratorRoute/MaterialColorGeneratorRoute';
// const Icon = (
// <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16">
// <path d="M0 4a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V4zm11.666 1.89c.682 0 1.139.47 1.187 1.107H14v-.11c-.053-1.187-1.024-2-2.342-2-1.604 0-2.518 1.05-2.518 2.751v.747c0 1.7.905 2.73 2.518 2.73 1.314 0 2.285-.792 2.342-1.939v-.114h-1.147c-.048.615-.497 1.05-1.187 1.05-.839 0-1.318-.62-1.318-1.727v-.742c0-1.112.488-1.754 1.318-1.754zm-6.188.926h.044L6.542 11h1.006L9 5.001H7.818l-.82 4.355h-.056L5.97 5.001h-.94l-.972 4.355h-.053l-.827-4.355H2L3.452 11h1.005l1.02-4.184z" />
Expand Down Expand Up @@ -167,6 +168,9 @@ function App() {
<li>
<Link to="/colorGenerator">ColorGenerator</Link>
</li>
<li>
<Link to="/material-color-generator">Meterial Color Generator</Link>
</li>
<li>
<Link to="/content">FancyContent</Link>
</li>
Expand Down Expand Up @@ -238,6 +242,7 @@ function App() {
<Route path="/chips" element={<ChipsRoute />} />
<Route path="/checkbox" element={<CheckboxRoute />} />
<Route path="/colorGenerator" element={<ColorGeneratorRoute />} />
<Route path="/material-color-generator" element={<MaterialColorGeneratorRoute />} />
<Route path="/content" element={<FancyContentRoute />} />
<Route path="/switches" element={<SwitchesRoute />} />
<Route path="/menu" element={<MenueRoute />} />
Expand Down
170 changes: 86 additions & 84 deletions src/Routes/ColorGeneratorRoute/ColorGeneratorRoute.tsx
Original file line number Diff line number Diff line change
@@ -1,95 +1,97 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import React from 'react';

import styled, { css } from 'styled-components';

import { FancyButton } from '@/components/organisms/FancyButton';
import { TLayer } from '@/types';
import themeStore from '../../design/theme/themeStore/themeStore';
import { TTheme } from '@/types/TTheme';

export default function ColorGeneratorRoute() {
const theme = themeStore((state) => state.theme);
const switchTheme = themeStore((state) => state.switchTheme);
//get keys of primary
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);
const primaryKeys = Object?.keys(theme.color.primary).map((key) => parseInt(key));
const accentKeys = Object?.keys(theme.color.accent).map((key) => parseInt(key));
const secondaryKeys = Object?.keys(theme.color.secondary).map((key) => parseInt(key));
const infoKeys = Object?.keys(theme.color.info).map((key) => parseInt(key));
const warningKeys = Object?.keys(theme.color.warning).map((key) => parseInt(key));
const errorKeys = Object?.keys(theme.color.error).map((key) => parseInt(key));
const successKeys = Object?.keys(theme.color.success).map((key) => parseInt(key));

return (
<div style={{ display: 'flex' }}>
<div>
{primaryKeys?.map((color, index) => {
return (
<div
key={index}
style={{ width: '100px', height: '100px', backgroundColor: theme.color.primary[color] }}
></div>
);
})}
</div>
<div>
{accentKeys?.map((color, index) => {
return (
<div
key={index}
style={{ width: '100px', height: '100px', backgroundColor: theme.color.accent[color] }}
></div>
);
})}
</div>
<div>
{infoKeys?.map((color, index) => {
return (
<div
key={index}
style={{ width: '100px', height: '100px', backgroundColor: theme.color.accent[color] }}
></div>
);
})}
</div>
<>
<div style={{ display: 'flex' }}>
<FancyButton label="Switch Theme" onClick={() => switchTheme()} />

<div>
{secondaryKeys?.map((color, index) => {
return (
<div
key={index}
style={{ width: '100px', height: '100px', backgroundColor: theme.color.secondary[color] }}
></div>
);
})}
</div>
<div>
{warningKeys?.map((color, index) => {
return (
<div
key={index}
style={{ width: '100px', height: '100px', backgroundColor: theme.color.warning[color] }}
></div>
);
})}
</div>
<div>
{errorKeys?.map((color, index) => {
return (
<div
key={index}
style={{ width: '100px', height: '100px', backgroundColor: theme.color.error[color] }}
></div>
);
})}
</div>
<div>
{successKeys?.map((color, index) => {
return (
<div
key={index}
style={{ width: '100px', height: '100px', backgroundColor: theme.color.success[color] }}
></div>
);
})}
<div>
{primaryKeys?.map((color, index) => {
return (
<div
key={index}
style={{ width: '100px', height: '100px', backgroundColor: theme.color.primary[color as TLayer] }}
></div>
);
})}
</div>

<div>
{secondaryKeys?.map((color, index) => {
return (
<div
key={index}
style={{ width: '100px', height: '100px', backgroundColor: theme.color.secondary[color as TLayer] }}
></div>
);
})}
</div>
<div>
{accentKeys?.map((color, index) => {
return (
<div
key={index}
style={{ width: '100px', height: '100px', backgroundColor: theme.color.accent[color as TLayer] }}
></div>
);
})}
</div>
<div>
{infoKeys?.map((color, index) => {
return (
<div
key={index}
style={{ width: '100px', height: '100px', backgroundColor: theme.color.info[color as TLayer] }}
></div>
);
})}
</div>

<div>
{warningKeys?.map((color, index) => {
return (
<div
key={index}
style={{ width: '100px', height: '100px', backgroundColor: theme.color.warning[color as TLayer] }}
></div>
);
})}
</div>
<div>
{errorKeys?.map((color, index) => {
return (
<div
key={index}
style={{ width: '100px', height: '100px', backgroundColor: theme.color.error[color as TLayer] }}
></div>
);
})}
</div>
<div>
{successKeys?.map((color, index) => {
return (
<div
key={index}
style={{ width: '100px', height: '100px', backgroundColor: theme.color.success[color as TLayer] }}
></div>
);
})}
</div>
</div>
</div>
</>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { FancyBox } from '@/components/atoms/FancyBox';
import { Typography } from '@/components/atoms/Typography';
import { FancyFlexBox } from '@/components/templates/FancyFlexBox';
import { generateMaterialColorPalette } from '@/design/designFunctions/generateMaterialColorPalette/generateMaterialColorPalette';
import { hexToHSL } from '@/design/designFunctions/hexToHSL/hexToHSL';
import { useState } from 'react';

export default function MaterialColorGeneratorRoute() {
const [baseColor, setBaseColor] = useState('#f32020');
const [isDark, setIsDark] = useState(false);

const palette = generateMaterialColorPalette({ baseHex: baseColor, isLightTheme: !isDark });

const getContrastText = (bgColor: string) => {
const { l } = hexToHSL(bgColor);
return l > 60 ? '#000000' : '#FFFFFF';
};

return (
<FancyBox>
<FancyFlexBox direction="column">
<Typography variant="bodytextLg">Material Color Palette</Typography>
<button onClick={() => setIsDark(!isDark)}>{isDark ? 'isDark' : 'IsLight'}</button>
</FancyFlexBox>
<FancyBox>
<div>
<input type="color" value={baseColor} onChange={(e) => setBaseColor(e.target.value)} />
<span>{baseColor}</span>
</div>

<FancyFlexBox direction="column" align="stretch" justify="center" gap={'sm'}>
{Object.entries(palette).map(([weight, color]) => (
<FancyBox
themeType="transparent"
borderRadius={'md'}
padding={'sm'}
key={weight}
style={{
backgroundColor: color,
color: getContrastText(color),
}}
>
<FancyFlexBox justify="space-around" align="center">
<div className="w-16 font-medium">{weight}</div>
<div>{color.toUpperCase()}</div>
</FancyFlexBox>
</FancyBox>
))}
</FancyFlexBox>

<div>
<p>Usage in CSS:</p>
<code>{`--color-primary-${isDark ? 'dark' : 'light'}: ${baseColor};`}</code>
</div>
</FancyBox>
</FancyBox>
);
}
1 change: 0 additions & 1 deletion src/Routes/MenuRoute/MenueRoute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import React, { useRef, useState } from 'react';
import { FancyButton } from '../../../lib';

import { DesignArea, DesignWrapper } from '../DesignWrapper/Wrapper';
import Popover from '../../components/shared/FancyPopover/Popover';
import FancyPopover from '../../components/shared/FancyPopover/FancyPopover';
import FancyMenueItem from '../../components/templates/FancyMenuItem/FancyMenuItem';
import { Menu } from '@/components/molecules/Menue';
Expand Down
5 changes: 5 additions & 0 deletions src/Routes/SkeletonRoute/SkeletonRoute.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { DesignArea, DesignWrapper } from '@/Routes/DesignWrapper/Wrapper';
import { SkeletonBox } from '@/components/atoms/SkeletonBox';
import FancySkeletonGrid from '@/components/templates/FancySkeletonGrid/FancySkeletonGrid';

export default function SkeletonRoute() {
Expand All @@ -9,6 +10,10 @@ export default function SkeletonRoute() {
gridAreas={['a a b b b b d', 'a a c c c c d', 'e e c c c c f', 'e e g g g g f', 'e e h h h h f']}
height="200px"
/> */}
{/* eslint-disable-next-line @typescript-eslint/no-unsafe-assignment */}
{[...Array(5)].map((_, index) => (
<SkeletonBox key={index} index={index} sizeH="md" sizeW="fit" borderRadius="md" />
))}

<FancySkeletonGrid
gridAreas={['a a b b b b b', 'a a c c c c d', 'e e c c c c f', 'e e g g g g f', 'e e h h h h f']}
Expand Down
Loading

0 comments on commit 7f44960

Please sign in to comment.