-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #291 from TobiTRy/buildIn--new-systemmessage-wich-…
…is-better-visible-and-looking Build in new systemmessage wich is better visible and looking
- Loading branch information
Showing
41 changed files
with
872 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,38 @@ | ||
import { TThemeArrayOrValueCSS } from '@/design/designFunctions/arrayToCssValues'; | ||
import { TSizeSettings } from '@/types/TSizeSettings'; | ||
import { TSizeSettingsExtended } from '@/types/TSizeSettings'; | ||
|
||
type TSizeObj = { | ||
padding: TThemeArrayOrValueCSS; | ||
borderRadius: TThemeArrayOrValueCSS; | ||
}; | ||
|
||
export const sizeSettings: TSizeSettings<TSizeObj> = { | ||
export const sizeSettings: TSizeSettingsExtended<TSizeObj> = { | ||
xxs: { | ||
padding: ['xxs'], | ||
borderRadius: 'xs', | ||
}, | ||
xs: { | ||
padding: ['xs'], | ||
borderRadius: 'xs', | ||
}, | ||
sm: { | ||
padding: ['xs', 'md'], | ||
padding: ['sm'], | ||
borderRadius: 'sm', | ||
}, | ||
md: { | ||
padding: ['md', 'lg'], | ||
padding: ['md'], | ||
borderRadius: 'md', | ||
}, | ||
lg: { | ||
padding: ['md', 'lg'], | ||
padding: ['lg'], | ||
borderRadius: 'lg', | ||
}, | ||
xl: { | ||
padding: ['xl'], | ||
borderRadius: 'xl', | ||
}, | ||
xxl: { | ||
padding: ['xxl'], | ||
borderRadius: 'xxl', | ||
}, | ||
}; |
1 change: 0 additions & 1 deletion
1
src/components/atoms/FancyProfilePicture/TFancyProfilePicture.model.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/components/atoms/SystemMessageBox/SystemMessageBox.style.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { TSystemMessageBox } from './TSystemMessageBox.model'; | ||
import { arrayToCssValues } from '@/design/designFunctions/arrayToCssValues'; | ||
import { getBackgroundColor } from '@/design/designFunctions/colorCalculatorForComponent'; | ||
import { themeStore } from '@/design/theme/themeStore'; | ||
import { TStyledPrefixAndOmiter } from '@/types/TStyledPrefixAndOmiter'; | ||
import { TTheme } from '@/types/TTheme'; | ||
import { css, styled } from 'styled-components'; | ||
|
||
type TStyledSystemMessage = TStyledPrefixAndOmiter<TSystemMessageBox, 'children' | 'sizeC'>; | ||
|
||
export const StyledStystemMessage = styled.div<{ theme: TTheme } & TStyledSystemMessage>` | ||
border-width: 1px; | ||
display: flex; | ||
align-items: center; | ||
transition: all 0.2s; | ||
border-radius: ${({ $borderRadius }) => arrayToCssValues($borderRadius, 'borderRadius')}; | ||
padding: ${({ $padding }) => arrayToCssValues($padding, 'spacing')}; | ||
margin: ${({ $margin }) => arrayToCssValues($margin, 'spacing')}; | ||
@supports (color: rgb(from white r g b)) { | ||
${({ theme, $themeType = 'error', $layer = 0 }) => { | ||
const color = getBackgroundColor({ theme, $themeType, $layer: $layer }); | ||
const isDarkTheme = themeStore((state) => state.isDarkTheme); | ||
return css` | ||
border-color: oklch(from ${color} l c h / 25%); | ||
border-width: 1px; | ||
border-style: solid; | ||
background: oklch(from ${color} calc(l * 1) c h / 20%); | ||
color: oklch(from ${color} calc(l * (${isDarkTheme ? 1.3 : 0.7})) c h); | ||
&::selection { | ||
background: oklch(from ${color} calc(l * 1.1) c h); | ||
color: oklch(from ${color} 1 c h); | ||
} | ||
`; | ||
}} | ||
} | ||
`; |
34 changes: 34 additions & 0 deletions
34
src/components/atoms/SystemMessageBox/SystemMessageBox.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { StyledStystemMessage } from './SystemMessageBox.style'; | ||
import { TSystemMessageBoxWithHTMLAttrs } from './TSystemMessageBox.model'; | ||
import { sizes } from './sizeSettings'; | ||
|
||
export default function SystemMessageBox(props: TSystemMessageBoxWithHTMLAttrs) { | ||
const { | ||
children, | ||
layer, | ||
sizeC = 'sm', | ||
themeType = 'error', | ||
padding, | ||
borderRadius, | ||
margin, | ||
externalStyle, | ||
role, | ||
} = props; | ||
|
||
const calcBorderRadius = borderRadius ? borderRadius : sizeC ? sizes[sizeC].borderRadius : undefined; | ||
const calcPadding = padding ? padding : sizeC ? sizes[sizeC].padding : undefined; | ||
|
||
return ( | ||
<StyledStystemMessage | ||
role={role ?? 'alert'} | ||
$padding={calcPadding} | ||
$margin={margin} | ||
$borderRadius={calcBorderRadius} | ||
$layer={layer} | ||
$themeType={themeType} | ||
$externalStyle={externalStyle} | ||
> | ||
{children} | ||
</StyledStystemMessage> | ||
); | ||
} |
20 changes: 20 additions & 0 deletions
20
src/components/atoms/SystemMessageBox/TSystemMessageBox.model.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { TThemeArrayOrValueCSS } from '@/design/designFunctions/arrayToCssValues'; | ||
import { TComponentSizes } from '@/types/TComponentSizes'; | ||
import { TLayer } from '@/types/TLayer'; | ||
import { TUiColorsNotTransparent } from '@/types/TUiColorsNotTransparent'; | ||
import { CSSProp } from 'styled-components'; | ||
|
||
export type TSystemMessageBox = { | ||
themeType?: TUiColorsNotTransparent; | ||
layer?: TLayer; | ||
children?: React.ReactNode; | ||
padding?: TThemeArrayOrValueCSS; | ||
margin?: TThemeArrayOrValueCSS; | ||
borderRadius?: TThemeArrayOrValueCSS; | ||
sizeC?: TComponentSizes; | ||
externalStyle?: CSSProp; | ||
}; | ||
|
||
export type TSystemMessageBoxHTMLAttrs = React.HTMLAttributes<HTMLDivElement>; | ||
|
||
export type TSystemMessageBoxWithHTMLAttrs = TSystemMessageBox & TSystemMessageBoxHTMLAttrs; |
31 changes: 31 additions & 0 deletions
31
src/components/atoms/SystemMessageBox/docu/SystemMessageBox.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { Meta, Controls, Canvas, Title, Description } from '@storybook/blocks'; | ||
|
||
import * as SystemMessageBox from './SystemMessageBox.stories'; | ||
|
||
<Meta of={SystemMessageBox} /> | ||
|
||
<Title /> | ||
|
||
## Overview | ||
|
||
<Description /> | ||
|
||
## Setup | ||
|
||
```jsx | ||
import { SystemMessageBox } from 'fui-fancyui'; | ||
``` | ||
|
||
### Example Usage | ||
|
||
Here’s a simple example of using the `SystemMessageBox`: | ||
|
||
```jsx | ||
<SystemMessageBox themeType="info" sizeC="md" padding="md"> | ||
This is an informational message. | ||
</SystemMessageBox> | ||
``` | ||
|
||
<Canvas /> | ||
|
||
<Controls /> |
75 changes: 75 additions & 0 deletions
75
src/components/atoms/SystemMessageBox/docu/SystemMessageBox.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
|
||
import SystemMessageBox from '../SystemMessageBox'; | ||
import templateThemeType from '@/stories/templateSettingsForStorys/templatesForThemeType'; | ||
|
||
const meta = { | ||
component: SystemMessageBox, | ||
title: 'components/atoms/SystemMessageBox', | ||
parameters: { | ||
docs: { | ||
description: { | ||
component: | ||
'The SystemMessageBox component is designed to display alerts or informational messages within an application. It supports various styling options based on themes, sizes, and layers to cater to different UI requirements.', | ||
}, | ||
}, | ||
}, | ||
argTypes: { | ||
...templateThemeType('notTransparent', 'error', 0), | ||
externalStyle: { | ||
description: | ||
'The style of the card can porvieed with the styled-component css and react style={{width: "100px"}}', | ||
control: { | ||
type: 'object', | ||
}, | ||
}, | ||
sizeC: { | ||
description: 'The size of the component.', | ||
control: { | ||
type: 'select', | ||
}, | ||
table: { | ||
defaultValue: { summary: 'sm' }, | ||
}, | ||
}, | ||
borderRadius: { | ||
description: 'The border radius of the component.', | ||
control: { | ||
type: 'text', | ||
}, | ||
table: { | ||
defaultValue: { summary: undefined }, | ||
}, | ||
}, | ||
padding: { | ||
description: 'The padding of the component.', | ||
control: { | ||
type: 'text', | ||
}, | ||
table: { | ||
defaultValue: { summary: undefined }, | ||
}, | ||
}, | ||
margin: { | ||
description: 'The margin of the component.', | ||
control: { | ||
type: 'text', | ||
}, | ||
table: { | ||
defaultValue: { summary: undefined }, | ||
}, | ||
}, | ||
}, | ||
} satisfies Meta<typeof SystemMessageBox>; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Primary: Story = { | ||
render: (args) => <SystemMessageBox {...args}>Moooiin</SystemMessageBox>, | ||
args: { | ||
themeType: 'error', | ||
sizeC: 'sm', | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export { default as SystemMessageBox } from './SystemMessageBox'; | ||
|
||
export type { TSystemMessageBox, TSystemMessageBoxWithHTMLAttrs } from './TSystemMessageBox.model'; |
Oops, something went wrong.