Skip to content

Commit

Permalink
update: some strcture of molecules
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiTRy committed Dec 4, 2023
1 parent e167c0c commit b543eac
Show file tree
Hide file tree
Showing 34 changed files with 285 additions and 243 deletions.
3 changes: 2 additions & 1 deletion lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export { default as RawSlider } from '@/components/atoms/RawSlider/RawSlider';
export { default as ScrollableBar } from '@/components/atoms/ScrollableBar/ScrollableBar';
export { default as SimpleDialog } from '@/components/atoms/SimpleDialog/SimpleDialog';
export { default as SingleInput } from '@/components/atoms/SingleInput/SingleInput';
export { default as Slot } from '@/components/atoms/Slot/Slot';
export { default as SwipeUpContainer } from '@/components/atoms/SwipeUpContainer/SwipeUpContainer';
export { default as SwipeUpDash } from '@/components/atoms/SwipeUpDash/SwipeUpDash';
export { default as Typography } from '@/components/atoms/Typography/Typography';
Expand Down Expand Up @@ -85,7 +84,9 @@ export { default as FancyMiniProfile } from '@/components/molecules/FancyMiniPro
export { default as FancyCheckbox } from '@/components/molecules/FancyCheckbox/FancyCheckbox';
export { default as FancyChip } from '@/components/organisms/FancyChip/FancyChip';
export { default as Header } from '@/components/molecules/Header/Header';
export { default as FancyContent } from '@/components/molecules/FancyContent/FancyContent';
export { default as InfoCard } from '@/components/molecules/InfoCard/InfoCard';
export { default as ComponentAndActionWrapper } from '@/components/molecules/ComponentAndActionWrapper/ComponentAndActionWrapper';

// ---------- Organisms ------- //
export { default as FancyColorPicker } from '@/components/organisms/FancyColorPicker/FancyColorPicker';
Expand Down
11 changes: 6 additions & 5 deletions src/components/molecules/BottomBar/BottomBar.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import React from 'react';
import { CSSProp, css } from 'styled-components';

import { TThemeTypes } from '@/interface/TThemeTypes';
import { TLayer } from '@/interface/TLayer';
import { FancyBox } from '../../atoms/FancyBox';
import { CSSProp, css } from 'styled-components';
import { FancyBox } from '@/components/atoms/FancyBox';
import { fancyBarStyle } from './BottomBar.style';

// --------------------------------------------------------------------------- //
// ------------------ The Bottom Bar for the mobile navigation --------------- //
// -------------- use the store to controle the bar from outside ------------ //
type TBottomBar = {
isVisible?: boolean;
themeType?: TThemeTypes;
layer?: TLayer;
externalStyle?: CSSProp;
children?: React.ReactNode;
} & React.ComponentProps<typeof FancyBox>;
// --------------------------------------------------------------------------- //
// ------------------ The Bottom Bar for the mobile navigation --------------- //
// -------------- use the store to controle the bar from outside ------------ //
export default function BottomBar(props: TBottomBar) {
const { isVisible, externalStyle, children, ...bottomBarProps } = { ...defaultProps, ...props };

Expand All @@ -36,6 +36,7 @@ export default function BottomBar(props: TBottomBar) {
);
}

// default props for the bottom bar
const defaultProps: TBottomBar = {
isVisible: true,
};
16 changes: 16 additions & 0 deletions src/components/molecules/Button/Button.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { CSSProp } from 'styled-components';
import { IGenerateThemeDesignForComponentProps } from '@/design/designFunctions/generateThemeDesignForComponent/generateThemeDesignForComponent';

export type IButtonProps = {
size?: 'sm' | 'md' | 'lg';
wide?: boolean;
children?: React.ReactNode;
externalStyle?: CSSProp;
disabled?: boolean;
} & IGenerateThemeDesignForComponentProps;

type ButtonHTML = React.ButtonHTMLAttributes<HTMLButtonElement>;
type AnchorHTML = React.AnchorHTMLAttributes<HTMLAnchorElement>;

// Using conditional type based on the 'as' prop
export type IButton = IButtonProps & (({ as?: 'button' } & ButtonHTML) | ({ as: 'a' } & AnchorHTML));
9 changes: 5 additions & 4 deletions src/components/molecules/Button/Button.style.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { styled } from 'styled-components';
import { disabledStyle } from '../../../design/designFunctions/disabledStyle/disableStyle';

import { disabledStyle } from '@/design/designFunctions/disabledStyle/disableStyle';
import generateThemeDesignForComponent, {
IGenerateThemeDesignForComponent,
} from '../../../design/designFunctions/generateThemeDesignForComponent/generateThemeDesignForComponent';
import IStyledPrefixAndPicker from '../../../interface/IStyledPrefixAndPicker.model';
import { IButtonProps } from './Button';
} from '@/design/designFunctions/generateThemeDesignForComponent/generateThemeDesignForComponent';
import IStyledPrefixAndPicker from '@/interface/IStyledPrefixAndPicker.model';
import { IButtonProps } from './Button.model';

export const StyledButton = styled.button<IGenerateThemeDesignForComponent & IStyledPrefixAndPicker<IButtonProps>>`
display: inline-flex;
Expand Down
20 changes: 3 additions & 17 deletions src/components/molecules/Button/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,8 @@
import React from 'react';
import { CSSProp } from 'styled-components';

import { IGenerateThemeDesignForComponentProps } from '../../../design/designFunctions/generateThemeDesignForComponent/generateThemeDesignForComponent';
import { StyledButton } from './Button.style';
import { IButton } from './Button.model';

export type IButtonProps = {
size?: 'sm' | 'md' | 'lg';
wide?: boolean;
children?: React.ReactNode;
externalStyle?: CSSProp;
disabled?: boolean;
} & IGenerateThemeDesignForComponentProps;

type ButtonHTML = React.ButtonHTMLAttributes<HTMLButtonElement>;
type AnchorHTML = React.AnchorHTMLAttributes<HTMLAnchorElement>;

// Using conditional type based on the 'as' prop
export type IButton = IButtonProps & (({ as?: 'button' } & ButtonHTML) | ({ as: 'a' } & AnchorHTML));
// --------------------------------------------------------------------------- //
// --------------- A normal Button with Style from the Theme ----------------- //
// --------------------------------------------------------------------------- //
Expand All @@ -42,8 +28,8 @@ export default function Button(props: IButton) {
);
}

const defaultProps: IButtonProps & IGenerateThemeDesignForComponentProps = {
const defaultProps = {
themeType: 'accent' as const,
size: 'md',
layer: 0,
layer: 0 as const,
};
4 changes: 2 additions & 2 deletions src/components/molecules/Chip/Chip.style.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { css, styled } from 'styled-components';

import generateThemeDesignForComponent from '../../../design/designFunctions/generateThemeDesignForComponent/generateThemeDesignForComponent';
import IStyledPrefixAndOmitter from '../../../interface/IStyledPrefixAndOmiter.model';
import generateThemeDesignForComponent from '@/design/designFunctions/generateThemeDesignForComponent/generateThemeDesignForComponent';
import IStyledPrefixAndOmitter from '@/interface/IStyledPrefixAndOmiter.model';
import { IStyledChip } from './Chip';
import { TTheme } from '@/interface/TTheme';

Expand Down
3 changes: 1 addition & 2 deletions src/components/molecules/Chip/Chip.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React from 'react';
import { CSSProp } from 'styled-components';

import { sizes } from '../FancyContent/utils/sizeSettings';
import { TThemeTypes } from '@/interface/TThemeTypes';
import { TLayer } from '@/interface/TLayer';
import { StyledChip } from './Chip.style';
import { TThemeTypesNotTransparent } from '@/interface/TThemeTypesNotTransparent';
import { sizes } from '@/components/molecules/FancyContent/utils/sizeSettings';

export interface IStyledChip {
size?: keyof typeof sizes;
Expand All @@ -19,7 +19,6 @@ export interface IStyledChip {
externalStyle?: CSSProp;
children?: React.ReactNode;
}

// --------------------------------------------------------------------------- //
// --------------- A Simple chip you can put everthing in it ---------------- //
// --------------------------------------------------------------------------- //
Expand Down
10 changes: 7 additions & 3 deletions src/components/molecules/ChipList/ChipList.style.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@ import { css, styled } from 'styled-components';

import themeStore from '@/design/theme/themeStore/themeStore';
import { TUiColorsSystemMessage } from '@/interface/TUiColorsSystemMessage';

import { generateSystemIndicatorStyle } from '@/design/designFunctions/generateSystemIndicatorStyle';

export const FancyBoxStyle = css``;

export const ChipContainer = styled.ul`
display: flex;
flex-wrap: wrap;
Expand All @@ -15,6 +12,13 @@ export const ChipContainer = styled.ul`
padding: 0;
`;

/**
* Generates the style for the ChipList component.
*
* @param size - The size of the ChipList ('sm', 'md', 'lg').
* @param sytemMessage - Optional system message color for the ChipList.
* @returns The generated style object for the ChipList.
*/
export const generateChipListStyle = (size: 'sm' | 'md' | 'lg', sytemMessage?: TUiColorsSystemMessage) => {
const styemIndicatorStyle = generateSystemIndicatorStyle(sytemMessage);
const getTheme = themeStore.getState().theme;
Expand Down
4 changes: 3 additions & 1 deletion src/components/molecules/ChipList/ChipList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ export interface ChipListProps {
size?: 'sm' | 'md' | 'lg';
systemMessage?: TUiColorsSystemMessage;
}

// --------------------------------------------------------------------------- //
// ---------- The Chiplist is a wrapper for the chips to list them ---------- //
// --------------------------------------------------------------------------- //
export default function ChipList(props: ChipListProps) {
const { themeType = 'primary', layer = 1, outlined = false, children, size, systemMessage } = props;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as ComponentAndActionWrapper } from './ComponentAndActionWrapper';
37 changes: 37 additions & 0 deletions src/components/molecules/FancyContent/FancyContent.style.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { styled } from 'styled-components';

import IStyledPrefixAndPicker from '@/interface/IStyledPrefixAndPicker.model';
import { TTheme } from '@/interface/TTheme';
import { IFancyContentProps } from './FancyContent';

// Define the types for the Wrapper component
type TWrapper = IStyledPrefixAndPicker<
IFancyContentProps,
'flexDirection' | 'flexAlign' | 'flexJustify' | 'gapBetweenText' | 'gapBetweenIcon'
>;

// Define the Wrapper component
export const Wrapper = styled.span<TWrapper & { theme: TTheme }>`
display: flex;
flex-direction: ${({ $flexDirection }) => $flexDirection || 'row'};
justify-content: ${({ $flexJustify }) => $flexJustify || 'center'};
align-items: ${({ $flexAlign }) => $flexAlign || 'center'};
gap: ${({ $gapBetweenIcon, theme }) => $gapBetweenIcon ?? theme.spacing.xs};
.content {
display: flex;
flex-direction: column;
justify-content: center;
align-items: flex-start;
gap: ${({ $gapBetweenText, theme }) => $gapBetweenText ?? theme.spacing.xxs};
}
`;

type TOnlyTextWrapper = IStyledPrefixAndPicker<IFancyContentProps, 'flexDirection' | 'gapBetweenText' | 'flexAlign' | 'flexJustify'>;
export const OnlyTextWrapper = styled.span<TOnlyTextWrapper & { theme: TTheme }>`
display: flex;
flex-direction: ${({ $flexDirection }) => $flexDirection || 'column'};
justify-content: ${({ $flexJustify }) => $flexJustify || 'center'};
align-items: ${({ $flexAlign }) => $flexAlign || 'flex-start'};
gap: ${({ $gapBetweenText, theme }) => $gapBetweenText ?? theme.spacing.xxs};
`;
38 changes: 2 additions & 36 deletions src/components/molecules/FancyContent/FancyContent.tsx
Original file line number Diff line number Diff line change
@@ -1,46 +1,12 @@
// Import necessary dependencies
import React, { ReactElement } from 'react';
import { styled } from 'styled-components';

import { FancyContentIcon } from './utils/FancyContentIcon';
import { FancyContentDescription, FancyContentTitle } from './utils/FancyContentText';
import IStyledPrefixAndPicker from '../../../interface/IStyledPrefixAndPicker.model';
import { TTheme } from '@/interface/TTheme';

// Define the types for the Wrapper component
type TWrapper = IStyledPrefixAndPicker<
IFancyContentProps,
'flexDirection' | 'flexAlign' | 'flexJustify' | 'gapBetweenText' | 'gapBetweenIcon'
>;

// Define the Wrapper component
const Wrapper = styled.span<TWrapper & { theme: TTheme }>`
display: flex;
flex-direction: ${({ $flexDirection }) => $flexDirection || 'row'};
justify-content: ${({ $flexJustify }) => $flexJustify || 'center'};
align-items: ${({ $flexAlign }) => $flexAlign || 'center'};
gap: ${({ $gapBetweenIcon, theme }) => $gapBetweenIcon ?? theme.spacing.xs};
.content {
display: flex;
flex-direction: column;
justify-content: center;
align-items: flex-start;
gap: ${({ $gapBetweenText, theme }) => $gapBetweenText ?? theme.spacing.xxs};
}
`;

type TOnlyTextWrapper = IStyledPrefixAndPicker<IFancyContentProps, 'flexDirection' | 'gapBetweenText' | 'flexAlign' | 'flexJustify'>;
const OnlyTextWrapper = styled.span<TOnlyTextWrapper & { theme: TTheme }>`
display: flex;
flex-direction: ${({ $flexDirection }) => $flexDirection || 'column'};
justify-content: ${({ $flexJustify }) => $flexJustify || 'center'};
align-items: ${({ $flexAlign }) => $flexAlign || 'flex-start'};
gap: ${({ $gapBetweenText, theme }) => $gapBetweenText ?? theme.spacing.xxs};
`;
import { OnlyTextWrapper, Wrapper } from './FancyContent.style';

// Define the props for the FancyContent component
interface IFancyContentProps {
export interface IFancyContentProps {
flexDirection?: 'row' | 'row-reverse' | 'column' | 'column-reverse';
flexJustify?: 'flex-start' | 'flex-end' | 'center' | 'space-between' | 'space-around' | 'space-evenly';
flexAlign?: 'flex-start' | 'flex-end' | 'center' | 'stretch' | 'baseline';
Expand Down
1 change: 1 addition & 0 deletions src/components/molecules/FancyContent/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as FancyContent } from './FancyContent';
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FancySVGAtom } from '../../../atoms/FancySVGAtom';
import { FancySVGAtom } from '@/components/atoms/FancySVGAtom';

interface IFancyContentIconProps {
children?: React.ReactNode;
Expand Down
37 changes: 10 additions & 27 deletions src/components/molecules/FancyContent/utils/FancyContentText.tsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,11 @@
import { CSSProp } from 'styled-components';

import Typography from '../../../atoms/Typography/Typography';
import { Typography } from '@/components/atoms/Typography';
import { TTextProps } from './TFancyTextVariant.model';
import { sizes } from './sizeSettings';
import { TTypography } from '@/interface/TTypography';

type IFancyContentTextProps = {
children?: React.ReactNode;
bold?: boolean;
className?: string;
externalStyle?: CSSProp;
};

type IFancyContentTextWithSizeProps = IFancyContentTextProps & {
size?: 'sm' | 'md' | 'lg';
fontVariant?: never;
};

type IFancyContentTextWithFontVariantProps = IFancyContentTextProps & {
fontVariant?: TTypography;
size?: never;
};

export function FancyContentTitle(
props: IFancyContentTextProps & (IFancyContentTextWithFontVariantProps | IFancyContentTextWithSizeProps)
) {
// --------------------------------------------------------------------------- //
// ----------------- The Title for the FancyContent component ---------------- //
// --------------------------------------------------------------------------- //
export function FancyContentTitle(props: TTextProps) {
const { size, bold = true, fontVariant, children, className, externalStyle } = props;

return (
Expand All @@ -39,9 +21,10 @@ export function FancyContentTitle(
);
}

export function FancyContentDescription(
props: IFancyContentTextProps & (IFancyContentTextWithFontVariantProps | IFancyContentTextWithSizeProps)
) {
// --------------------------------------------------------------------------- //
// -------------- The description for the FancyContent component ------------- //
// --------------------------------------------------------------------------- //
export function FancyContentDescription(props: TTextProps) {
const { size, bold, fontVariant, children, className, externalStyle } = props;

return (
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { CSSProp } from 'styled-components';
import { TTypography } from '@/interface/TTypography';

type IFancyContentTextProps = {
children?: React.ReactNode;
bold?: boolean;
className?: string;
externalStyle?: CSSProp;
};

type IFancyContentTextWithSizeProps = IFancyContentTextProps & {
size?: 'sm' | 'md' | 'lg';
fontVariant?: never;
};

type IFancyContentTextWithFontVariantProps = IFancyContentTextProps & {
fontVariant?: TTypography;
size?: never;
};

/**
* Represents the type definition for the `TTextProps` type.
* This type is a combination of `IFancyContentTextProps` and either `IFancyContentTextWithFontVariantProps` or `IFancyContentTextWithSizeProps`.
*/
export type TTextProps = IFancyContentTextProps & (IFancyContentTextWithFontVariantProps | IFancyContentTextWithSizeProps);
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';

import FancyCard from '../../atoms/FancyCard/FancyCard';
import Typography from '../../atoms/Typography/Typography';
import { FancyCard } from '@/components/atoms/FancyCard';
import { Typography } from '@/components/atoms/Typography';
import { styled } from 'styled-components';

interface IContentCardProps {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { styled, css } from 'styled-components';

import calcBorderRadiusOnAlignment from '../../../design/designFunctions/calcBorderRadiusOnAlignment/calcBorderRadiusOnAlignment';
import { IFancyUL } from './FancyDropDownUL';
import IStyledPrefixAndPicker from '../../../interface/IStyledPrefixAndPicker.model';
import { boxShadow } from '../../../design/designFunctions/shadows/shadows';
import { TThemeTypes } from '@/interface/TThemeTypes';
import { TLayer } from '@/interface/TLayer';
import { getBackgroundColor } from '../../../design/designFunctions/colorCalculatorForComponent/colorCalculatorForComponent';
import { TTheme } from '@/interface/TTheme';
import { TLayer } from '@/interface/TLayer';
import IStyledPrefixAndPicker from '@/interface/IStyledPrefixAndPicker.model';
import calcBorderRadiusOnAlignment from '@/design/designFunctions/calcBorderRadiusOnAlignment/calcBorderRadiusOnAlignment';
import { getBackgroundColor } from '@/design/designFunctions/colorCalculatorForComponent/colorCalculatorForComponent';
import { boxShadow } from '@/design/designFunctions/shadows/shadows';
import { IFancyUL } from './FancyDropDownUL';

// --------------------------------------------------------------------------- //
// ------- the generator function for the Wrapper of the UL ------------------ //
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useEffect, useRef } from 'react';

import { animated, useSpring } from '@react-spring/web';

import { StyledUL, WrapperUL } from './FancyDropDownUL.style';
import { TThemeTypes } from '@/interface/TThemeTypes';
import { TLayer } from '@/interface/TLayer';
Expand Down
Loading

0 comments on commit b543eac

Please sign in to comment.