Skip to content

Commit

Permalink
structure: molecules
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiTRy committed Dec 4, 2023
1 parent d222c20 commit e167c0c
Show file tree
Hide file tree
Showing 34 changed files with 167 additions and 261 deletions.
2 changes: 1 addition & 1 deletion lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export { default as PasswordEye } from '@/components/atoms/PasswordEye/PasswordE
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 SingleInputAtom } from '@/components/atoms/SingleInputAtom/SingleInputAtom';
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';
Expand Down
4 changes: 2 additions & 2 deletions src/components/atoms/FancyCard/FancyCard.style.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import IStyledPrefixAndOmiter from '../../../interface/IStyledPrefixAndOmiter.mo
import { spacingPx } from '../../../design/theme/designSizes';
import edgeCalculation from '../../../design/designFunctions/edgeCalculation/edgeCalculation';

import { boxShadow } from '../../../design/designFunctions/shadows/shadows';
import getColorsForComponent from '../../../design/designFunctions/colorCalculatorForComponent/colorCalculatorForComponent';
import { boxShadow } from '@/design/designFunctions/shadows/shadows';
import { getColorsForComponent } from '@/design/designFunctions/colorCalculatorForComponent';
import { TTheme } from '@/interface/TTheme';

// the converted $ styling props for the card
Expand Down
3 changes: 0 additions & 3 deletions src/components/atoms/ProgressBar/ProgressBar.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import React from 'react';
import { styled } from 'styled-components';

import { TThemeTypes } from '@/interface/TThemeTypes';
import { TLayer } from '@/interface/TLayer';
import { getBackgroundColor } from '../../../design/designFunctions/colorCalculatorForComponent/colorCalculatorForComponent';
import { TTheme } from '@/interface/TTheme';
import { ProgressBarContainer, ProgressBarFill } from './ProgressBar.style';

// Define the interface for the progress bar props
Expand Down
2 changes: 1 addition & 1 deletion src/components/atoms/RawCheckbox/RawCheckbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useState, useEffect } from 'react';

import { FakeCheckbox, HidenCheckBox, InputContainer } from './RawCheckbox.style';
import { IRawCheckboxProps } from './RawCheckbox.model';
import SVGCheckMark from '../../icons/SVGCheckMark/SVGCheckMark';
import { SVGCheckMark } from '@/components/icons/SVGCheckMark';

// --------------------------------------------------------------------------- //
// -------------------- A simple Checkbox with a Label ----------------------- //
Expand Down
2 changes: 1 addition & 1 deletion src/components/atoms/RawInput/RawInput.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { styled } from 'styled-components';

import { fontSize } from '../../../design/theme/designSizes';
import { fontSize } from '@/design/theme/designSizes';
import { TTheme } from '@/interface/TTheme';

export type TRawInputAlign = 'left' | 'center';
Expand Down
1 change: 1 addition & 0 deletions src/components/atoms/RawNav/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as RawNav } from './RawNav';
1 change: 1 addition & 0 deletions src/components/atoms/RawSlider/RawSlider.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { InputHTMLAttributes, useRef } from 'react';

import { StyledRawSlider } from './RawSlider.style';
import { TLayer } from '@/interface/TLayer';
import { TThemeTypes } from '@/interface/TThemeTypes';
Expand Down
1 change: 1 addition & 0 deletions src/components/atoms/RawUL/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as RawUL } from './RawUL';
22 changes: 22 additions & 0 deletions src/components/atoms/SimpleDialog/SimpleDialog.style.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { styled } from 'styled-components';
import { getColorsForComponent } from '@/design/designFunctions/colorCalculatorForComponent';

import { TLayer } from '@/interface/TLayer';
import { TTheme } from '@/interface/TTheme';
import { TThemeTypes } from '@/interface/TThemeTypes';
import { animated } from '@react-spring/web';

// Define the styled component for the dialog
export const StyledDialog = styled(animated.div)<{ theme: TTheme; $themeType?: TThemeTypes; $layer?: TLayer }>`
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
padding: ${({ theme }) => theme.spacing.xl};
border-radius: ${({ theme }) => theme.borderRadius.lg};
border: none;
width: 70%;
max-height: 85%;
${({ theme, $themeType = 'primary', $layer = 1 }) => getColorsForComponent({ theme, $themeType, $layer })}
z-index: 1000;
`;
19 changes: 1 addition & 18 deletions src/components/atoms/SimpleDialog/SimpleDialog.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,9 @@
import React, { useEffect, useState } from 'react';
import { styled } from 'styled-components';
import { animated, useSpring } from '@react-spring/web';

import { TThemeTypes } from '@/interface/TThemeTypes';
import { TLayer } from '@/interface/TLayer';
import getColorsForComponent from '../../../design/designFunctions/colorCalculatorForComponent/colorCalculatorForComponent';
import { TTheme } from '@/interface/TTheme';

// Define the styled component for the dialog
const StyledDialog = styled(animated.div)<{ theme: TTheme; $themeType?: TThemeTypes; $layer?: TLayer }>`
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
padding: ${({ theme }) => theme.spacing.xl};
border-radius: ${({ theme }) => theme.borderRadius.lg};
border: none;
width: 70%;
max-height: 85%;
${({ theme, $themeType = 'primary', $layer = 1 }) => getColorsForComponent({ theme, $themeType, $layer })}
z-index: 1000;
`;
import { StyledDialog } from './SimpleDialog.style';

// Define the props for the SimpleDialog component
interface ISimpleDialog {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { Meta, StoryObj } from '@storybook/react';

// Import the component to be tested
import { SingleInputAtom } from './SingleInputAtom';
import { SingleInputAtom } from './SingleInput';

// fix for building ... because storybook is not able to handle the default export
const HelperComponent = (props: React.ComponentProps<typeof SingleInputAtom>) => <SingleInputAtom {...props} />;
Expand Down
31 changes: 31 additions & 0 deletions src/components/atoms/SingleInput/SingleInput.style.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { styled } from 'styled-components';

import { TLayer } from '@/interface/TLayer';
import { TThemeTypes } from '@/interface/TThemeTypes';
import { getBackgroundColor } from '@/design/designFunctions/colorCalculatorForComponent';
import { TTheme } from '@/interface/TTheme';
import { fontSize } from '@/design/theme/designSizes';

// the style for a single input
interface StyledSingleInputProps {
$hasValue: boolean;
$isFocused: boolean;
$themeType?: TThemeTypes;
$layer?: TLayer;
}
export const StyledSingleInput = styled.input<StyledSingleInputProps & { theme: TTheme }>`
aspect-ratio: 4/5;
width: 1.5ch;
font-size: ${fontSize.xxl};
text-align: center;
color: ${({ theme }) => theme.colors.secondary[0]};
border: 1.5px solid
${({ $hasValue, theme, $themeType = 'secondary', $layer }) =>
$hasValue ? theme.colors.accent[0] : getBackgroundColor({ theme, $themeType, $layer })};
border-radius: 5px;
padding: ${({ theme }) => theme.spacing.xs};
background-color: transparent;
appearance: none;
outline: none;
box-shadow: ${({ $isFocused, theme }) => ($isFocused ? `0 0 2px 1px${theme.colors.accent[1]}` : 'none')};
`;
41 changes: 41 additions & 0 deletions src/components/atoms/SingleInput/SingleInput.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import React, { forwardRef, useState } from 'react';

import { TThemeTypes } from '@/interface/TThemeTypes';
import { TLayer } from '@/interface/TLayer';
import { StyledSingleInput } from './SingleInput.style';

// --------------------------------------------------------------------------- //
// --------- A Single Letter/NumberInput for a Verification process ---------- //
// --------------------------------------------------------------------------- //
interface ISingleInputAtomProps {
value: string;
ariaLabel?: string;
onKeyDown?: (e: React.KeyboardEvent<HTMLInputElement>) => void;
themeType?: TThemeTypes;
layer?: TLayer;
}
const SingleInputAtom = forwardRef<HTMLInputElement, ISingleInputAtomProps>((props, ref) => {
const { value, ariaLabel, onKeyDown, themeType, layer } = props;
const [isFocused, setIsFocused] = useState(false);

return (
<StyledSingleInput
type="text"
$themeType={themeType}
$layer={layer}
maxLength={1}
value={value}
onKeyDown={onKeyDown}
ref={ref}
aria-label={ariaLabel}
// eslint-disable-next-line @typescript-eslint/no-empty-function
onChange={() => {}}
onFocus={() => setIsFocused(true)}
onBlur={() => setIsFocused(false)}
$hasValue={value.length > 0}
$isFocused={isFocused}
/>
);
});

export default SingleInputAtom;
1 change: 1 addition & 0 deletions src/components/atoms/SingleInput/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as SingleInput } from './SingleInput';
69 changes: 0 additions & 69 deletions src/components/atoms/SingleInputAtom/SingleInputAtom.tsx

This file was deleted.

1 change: 0 additions & 1 deletion src/components/atoms/SingleInputAtom/index.ts

This file was deleted.

4 changes: 2 additions & 2 deletions src/components/atoms/SliderMarker/SliderMarker.style.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { styled } from 'styled-components';

import { TTheme } from '../../../interface/TTheme';
import colorTransparencyCalculator from '../../../design/designFunctions/colorTransparencyCalculator/colorTransparencyCalculator';
import { TTheme } from '@/interface/TTheme';
import { colorTransparencyCalculator } from '@/design/designFunctions/colorTransparencyCalculator';

export const WrapperMarker = styled.div`
position: absolute;
Expand Down
2 changes: 1 addition & 1 deletion src/components/atoms/SliderMarker/SliderMarker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default function SliderMarker({ position, children }: ISliderMarker) {
<WrapperMarker style={{ left: `${position}` }}>
<Marker>
{/* the children can use to display something in the marker like the color indicator that moves with the marker */}
{children && children}
{children}
</Marker>
</WrapperMarker>
);
Expand Down
59 changes: 0 additions & 59 deletions src/components/atoms/Slot/Slot.stories.tsx

This file was deleted.

39 changes: 0 additions & 39 deletions src/components/atoms/Slot/Slot.tsx

This file was deleted.

1 change: 0 additions & 1 deletion src/components/atoms/Slot/index.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import styled, { css } from 'styled-components';

import { fontSize } from '../../../design/theme/designSizes';
import { boxShadow, textShadow } from '../../../design/designFunctions/shadows/shadows';
import { fontSize } from '@/design/theme/designSizes';
import { boxShadow, textShadow } from '@/design/designFunctions/shadows/shadows';
import { TTheme } from '@/interface/TTheme';

export const MenueItemContainer = styled.div<{ $isOpen?: boolean; $index: number }>`
Expand Down
Loading

0 comments on commit e167c0c

Please sign in to comment.