Skip to content

Commit

Permalink
Merge pull request #293 from TobiTRy/fix-some-issue
Browse files Browse the repository at this point in the history
Fix some issue
  • Loading branch information
TobiTRy authored May 16, 2024
2 parents 2d178aa + 2a122b3 commit 47f0b58
Show file tree
Hide file tree
Showing 19 changed files with 86 additions and 15 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"name": "TobiTRy"
},
"private": false,
"version": "0.4.8",
"version": "0.4.9",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
4 changes: 4 additions & 0 deletions src/Routes/ExperimentalRoute/ExperimentalRoute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import createMultiIntersectionObserver from '@/utils/hooks/useMiltiIntersectionO
import { FancyVirtualScroll } from '@/components/shared/FancyVirtualScroll';
import ActionItem from '@/components/molecules/ActionItem/ActionItem';
import { AutoSizingBox } from '@/components/atoms/AutoSizingBox';
import { FancyBox } from '@/components/atoms/FancyBox';

const Icon = (
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16">
Expand Down Expand Up @@ -146,6 +147,9 @@ export default function ExperimentalRoute() {
<>
<DesignWrapper>
<DesignArea title="Test">
<FancyBox themeType="secondary" outlined>
Mooiin
</FancyBox>
<AutoSizingBox adjustHeight>
<Button sizeC={undefined} onClick={addContent}>
Mooiin
Expand Down
3 changes: 2 additions & 1 deletion src/components/molecules/InputWrapper/InputWrapper.style.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ import { styled, css } from 'styled-components';
import { disabledStyle } from '@/design/designFunctions/disabledStyle';
import { TTheme } from '@/types/TTheme';

export const StyledInputWrapper = styled.div<{ disabled?: boolean; $autoWidth?: boolean }>`
export const StyledInputWrapper = styled.div<{ disabled?: boolean; $autoWidth?: boolean; theme: TTheme }>`
position: relative;
display: grid;
grid-template-columns: auto 1fr auto;
grid-template-rows: 1fr auto;
width: ${({ $autoWidth }) => ($autoWidth ? 'auto' : '100%')};
border-radius: ${({ theme }) => theme.borderRadius.sm};
${({ disabled }) => (disabled ? disabledStyle : '')};
`;
Expand Down
5 changes: 4 additions & 1 deletion src/components/molecules/InputWrapper/InputWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,25 @@ export default function InputWrapper(props: TInputWrapper) {
layer = 2,
outlined,
outlinedBackgroundStrength,
outlinedRemoveBorder,
themeType = 'primary',
transparentBackground,
externalStyle,
labelVariant,
className,
} = props;

const theme = themeStore((state) => state.theme);

// Render the InputWrapper component with the appropriate props
return (
<StyledInputWrapper disabled={disabled} $autoWidth={autoWidth}>
<StyledInputWrapper disabled={disabled} className={className} $autoWidth={autoWidth}>
<FancyBox
themeType={transparentBackground ? 'transparent' : themeType}
layer={layer}
outlined={outlined}
outlinedBackgroundStrength={outlinedBackgroundStrength}
outlinedRemoveBorder={outlinedRemoveBorder}
externalStyle={css`
${generateInputContainerStyle(!!label, isActive, theme)}
${externalStyle}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export type TInputWrapper = {
placeholder?: string;
transparentBackground?: boolean;
labelVariant?: 'static' | 'animated';
className?: string;
} & Exclude<TFancyBox, 'as' | 'themeType' | 'externalStyle' | 'borderRadius' | 'sizeC'>;

export type TInputWrapperUserInputProps = Omit<
Expand Down
6 changes: 6 additions & 0 deletions src/components/organisms/FancyDateInput/FancyDateInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ export default function FancyDateInput(props: TFancyDateInput) {
underline,
onChange,
transparentBackground,
outlinedBackgroundStrength,
outlinedRemoveBorder,
externalStyle,
className,
...inputProps
} = props;

Expand Down Expand Up @@ -57,8 +60,11 @@ export default function FancyDateInput(props: TFancyDateInput) {
underline={underline}
layer={layer}
align={align}
className={className}
isActive={isActiveState}
icon={icon}
outlinedBackgroundStrength={outlinedBackgroundStrength}
outlinedRemoveBorder={outlinedRemoveBorder}
systemMessage={systemMessage}
transparentBackground={transparentBackground}
externalStyle={externalStyle}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export default function FancyDropDownSelect(props: TFancyDropDownSelect) {
themeType,
outlined,
outlinedBackgroundStrength,
outlinedRemoveBorder,
className,
layer,
onFocus,
onBlur,
Expand All @@ -44,6 +46,8 @@ export default function FancyDropDownSelect(props: TFancyDropDownSelect) {
label={label}
outlined={outlined}
outlinedBackgroundStrength={outlinedBackgroundStrength}
outlinedRemoveBorder={outlinedRemoveBorder}
className={className}
disabled={disabled}
align={align}
isActive={isActive}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ export default function FancyNumberInput(props: TFancyNumberInput) {
onFocus,
onBlur,
transparentBackground,
outlined,
outlinedBackgroundStrength,
outlinedRemoveBorder,
externalStyle,
className,
...inputProps
} = props;

Expand All @@ -52,6 +56,10 @@ export default function FancyNumberInput(props: TFancyNumberInput) {
systemMessage={systemMessage}
themeType={themeType}
layer={layer}
className={className}
outlined={outlined}
outlinedBackgroundStrength={outlinedBackgroundStrength}
outlinedRemoveBorder={outlinedRemoveBorder}
transparentBackground={transparentBackground}
InputElement={
<NumberInput
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ export default function FancyPasswordInput(props: TFancyPasswordInput) {
underline,
onBlur,
transparentBackground,
outlined,
outlinedBackgroundStrength,
outlinedRemoveBorder,
className,
...inputProps
} = props;

Expand All @@ -48,8 +52,12 @@ export default function FancyPasswordInput(props: TFancyPasswordInput) {
underline={underline}
isActive={isActive}
icon={icon}
className={className}
systemMessage={systemMessage}
transparentBackground={transparentBackground}
outlined={outlined}
outlinedBackgroundStrength={outlinedBackgroundStrength}
outlinedRemoveBorder={outlinedRemoveBorder}
InputElement={
<PasswordInput
id={usedId}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ export default function FancyRangeSlider(props: TFancyRangeSlider) {
align,
placeholder,
themeType,
outlined,
outlinedBackgroundStrength,
outlinedRemoveBorder,
disabled,
className,
...sliderProps
} = props;

Expand Down Expand Up @@ -65,6 +69,10 @@ export default function FancyRangeSlider(props: TFancyRangeSlider) {
id={usedId}
label={label}
hasValue={toutched}
outlined={outlined}
outlinedBackgroundStrength={outlinedBackgroundStrength}
outlinedRemoveBorder={outlinedRemoveBorder}
className={className}
underline={false}
isActive={toutched}
transparentBackground={transparentBackground}
Expand Down
8 changes: 8 additions & 0 deletions src/components/organisms/FancyTextInput/FancyTextInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ export default function FancyTextInput(props: TFancyTextInput) {
type = 'text',
underline,
onBlur,
outlined,
outlinedBackgroundStrength,
outlinedRemoveBorder,
transparentBackground,
className,
...inputProps
} = props;

Expand All @@ -47,8 +51,12 @@ export default function FancyTextInput(props: TFancyTextInput) {
isActive={isActive}
underline={underline}
icon={icon}
className={className}
systemMessage={systemMessage}
transparentBackground={transparentBackground}
outlined={outlined}
outlinedBackgroundStrength={outlinedBackgroundStrength}
outlinedRemoveBorder={outlinedRemoveBorder}
InputElement={
<TextInput
id={usedId}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ export default function FancyToastMessage() {
return (
<ToastsWrapper>
{transitions(({ ...style }, item: TToastMessage) => (
<animated.div key={item.id} style={style}>
<animated.aside role="alert" key={item.id} style={style}>
<SingleToastMessage
ref={(ref: HTMLDivElement) => ref && refMap.set(item, ref)}
toast={item}
remove={removeToast}
/>
</animated.div>
</animated.aside>
))}
</ToastsWrapper>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const ExampleComponent = () => {
const styleProps = {
themeType: 'accent', // accent is default
outlined: false, // false is default
backgroundStrength: 0.05, // 0.05 is default
backgroundStrength: 0.5, // 0.05 is default
backgroundState: 'hover', // hover is default
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type TGenerateOutlineStyle = Pick<
// ------- Generates the style for a outlined box or other compoent ---------- //
// --------------------------------------------------------------------------- //
export const generateOutlineStyle = (props: TGenerateOutlineStyle) => {
const { $themeType, theme, $layer, $backgroundState, $backgroundStrength = 0.05, $textColor } = props;
const { $themeType, theme, $layer, $backgroundState, $backgroundStrength = 0.1, $textColor } = props;

// generates the color for the border
const borderColor = getBackgroundColor({ theme, $themeType: $themeType ?? 'primary', $layer: $layer ?? 0 });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { css } from 'styled-components';
import { IGenerateThemeDesignForComponent } from '../generateThemeDesignForComponent';
import { generateStateStyle } from './generateHoverActiveColor';
import { generateTextColor } from './generateTextColor';
import { themeStore } from '@/design/theme/themeStore';

type TGenerateTransparentStyle = Pick<
IGenerateThemeDesignForComponent,
Expand All @@ -15,17 +16,24 @@ type TGenerateTransparentStyle = Pick<
| '$textColor'
| '$textHover'
>;
// --------------------------------------------------------------------------- //
// -------------------------------------------------------- //
// ---------- generates a transparent background ---------- //
// --------------------------------------------------------------------------- //
// --------------------------------------------------------- //
export const generateTransparentStyle = (props: TGenerateTransparentStyle) => {
const { $backgroundState, $textColor, $backgroundStrength = 0.3, $layer, $textHover } = props;

const getBackgroundStrength = themeStore((state) => state.theme.outlined.backgroundStrength);

return css`
color: ${generateTextColor({ $layer, $themeType: $textColor })};
${$backgroundState !== 'active' && 'background-color: transparent'};
/* This generate the hover / active style if its needed */
${$backgroundState &&
generateStateStyle({ ...props, $backgroundStrength, $textHover: $textHover, $textColor: $textColor })}
generateStateStyle({
...props,
$backgroundStrength: $backgroundStrength || getBackgroundStrength,
$textHover: $textHover,
$textColor: $textColor,
})}
`;
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { TStyledPrefixAndPicker } from '../../../types/TStyledPrefixAndPicker';
import { getBackgroundColor } from '../colorCalculatorForComponent/colorCalculatorForComponent';
import colorTransparencyCalculator from '../colorTransparencyCalculator/colorTransparencyCalculator';
import { IGenerateThemeForCardProps } from './IGenerateThemeForCardProps';
import { themeStore } from '@/design/theme/themeStore';

const generateOutlineStyle = (props: TGenerateColorDesign) => {
const { $themeType, theme, $layer = 3, $outlinedBackgroundStrength = 0.5, $outlinedRemoveBorder } = props;
Expand All @@ -18,8 +19,12 @@ const generateOutlineStyle = (props: TGenerateColorDesign) => {
);

return css`
background-color: ${$outlinedRemoveBorder && generateSlightBackgroundColor};
border: 1.5px solid ${backgroundColor};
background-color: ${generateSlightBackgroundColor};
${!$outlinedRemoveBorder &&
css`
border: 1.5px solid ${backgroundColor};
`};
`;
};

Expand All @@ -30,8 +35,9 @@ type TGenerateColorDesign = TStyledPrefixAndPicker<IGenerateThemeForCardProps> &
theme: TTheme;
};
export default function generateThemeForCard(props: TGenerateColorDesign) {
const { $themeType, theme, $outlined, $layer, $outlinedBackgroundStrength, $outlinedRemoveBorder = true } = props;
const { $themeType, theme, $outlined, $layer, $outlinedBackgroundStrength, $outlinedRemoveBorder } = props;
let outlinedStyle, backgroundColor;
const getBackgroundStrength = themeStore((state) => state.theme.outlined.backgroundStrength);

// generate the outlined style if the outlined prop is true else generate only the background color
if ($outlined) {
Expand All @@ -40,7 +46,7 @@ export default function generateThemeForCard(props: TGenerateColorDesign) {
$themeType,
theme,
$layer,
$outlinedBackgroundStrength,
$outlinedBackgroundStrength: $outlinedBackgroundStrength || getBackgroundStrength,
$outlinedRemoveBorder,
});
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export type TThemeValue = string | TThemeObject;
export type TThemeValue = string | number | TThemeObject;

export type TThemeObject = {
[key: string]: TThemeValue;
Expand Down
3 changes: 3 additions & 0 deletions src/design/theme/themeStore/themeStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ const themeStore = create<ThemeState>((set) => ({
fontSizes: typography,
breakpoints: breakpoints,
globalElementSizes: globalElementsizes,
outlined: {
backgroundStrength: 0.5,
},
},
isDarkTheme: true,
switchTheme: () => {
Expand Down
3 changes: 3 additions & 0 deletions src/types/TTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,7 @@ export type TTheme = {
globalElementSizes: {
[key in keyof typeof globalElementsizes]: string;
};
outlined: {
backgroundStrength: number;
};
};

0 comments on commit 47f0b58

Please sign in to comment.