-
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.
- Loading branch information
Showing
10 changed files
with
167 additions
and
0 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
packages/components/src/components/Align/Align.module.scss
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,30 @@ | ||
.align { | ||
display: flex; | ||
gap: var(--align--avatar-text--spacing); | ||
|
||
.text { | ||
font-size: var(--font-size-text--s); | ||
flex-grow: 1; | ||
display: flex; | ||
flex-direction: column; | ||
align-self: center; | ||
|
||
b { | ||
font-size: var(--font-size-text--m); | ||
} | ||
} | ||
|
||
--first-two-lines-height: calc(var(--line-height--s) * 2); | ||
|
||
&:has(b) { | ||
--first-two-lines-height: calc( | ||
var(--line-height--m) + var(--line-height--s) | ||
); | ||
} | ||
|
||
.avatar { | ||
margin-top: calc( | ||
(var(--first-two-lines-height) - var(--avatar--size--m)) / 2 | ||
); | ||
} | ||
} |
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,28 @@ | ||
import type { FC, PropsWithChildren } from "react"; | ||
import React from "react"; | ||
import styles from "./Align.module.scss"; | ||
import clsx from "clsx"; | ||
import type { PropsContext } from "@/lib/propsContext"; | ||
import PropsContextProvider from "@/lib/propsContext/PropsContextProvider"; | ||
import type { PropsWithClassName } from "@/lib/types/props"; | ||
|
||
export interface AlignProps extends PropsWithChildren, PropsWithClassName {} | ||
|
||
export const Align: FC<AlignProps> = (props) => { | ||
const { children, className } = props; | ||
|
||
const rootClassName = clsx(styles.align, className); | ||
|
||
const propsContext: PropsContext = { | ||
Text: { className: styles.text }, | ||
Avatar: { className: styles.avatar, size: "m" }, | ||
}; | ||
|
||
return ( | ||
<PropsContextProvider props={propsContext}> | ||
<div className={rootClassName}>{children}</div> | ||
</PropsContextProvider> | ||
); | ||
}; | ||
|
||
export default Align; |
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,4 @@ | ||
import { Align } from "./Align"; | ||
|
||
export { type AlignProps, Align } from "./Align"; | ||
export default Align; |
73 changes: 73 additions & 0 deletions
73
packages/components/src/components/Align/stories/Default.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,73 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
import React from "react"; | ||
import { Align } from "@/components/Align"; | ||
import { Avatar } from "@/components/Avatar"; | ||
import { Initials } from "@/components/Initials"; | ||
import { Text } from "@/components/Text"; | ||
|
||
const meta: Meta<typeof Align> = { | ||
title: "Structure/Align/Avatar + Text", | ||
component: Align, | ||
render: (props) => ( | ||
<Align {...props}> | ||
<Avatar> | ||
<Initials>Max Mustermann</Initials> | ||
</Avatar> | ||
<Text> | ||
<b>Max Mustermann</b> | ||
Organisationsinhaber | ||
</Text> | ||
</Align> | ||
), | ||
}; | ||
export default meta; | ||
|
||
type Story = StoryObj<typeof Align>; | ||
|
||
export const Default: Story = {}; | ||
|
||
export const Multiline: Story = { | ||
render: (props) => ( | ||
<Align {...props}> | ||
<Avatar> | ||
<Initials>Max Mustermann</Initials> | ||
</Avatar> | ||
<Text> | ||
<b>Max Mustermann</b> | ||
Organisationsinhaber | ||
<br /> | ||
[email protected] | ||
<br /> | ||
0163/123456789 | ||
</Text> | ||
</Align> | ||
), | ||
}; | ||
|
||
export const Singleline: Story = { | ||
render: (props) => ( | ||
<Align {...props}> | ||
<Avatar> | ||
<Initials>Max Mustermann</Initials> | ||
</Avatar> | ||
<Text> | ||
<b>Max Mustermann</b> | ||
</Text> | ||
</Align> | ||
), | ||
}; | ||
|
||
export const WithoutBoldText: Story = { | ||
render: (props) => ( | ||
<Align {...props}> | ||
<Avatar> | ||
<Initials>Max Mustermann</Initials> | ||
</Avatar> | ||
<Text> | ||
Max Mustermann | ||
<br /> | ||
Organisationsinhaber | ||
</Text> | ||
</Align> | ||
), | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
align: | ||
avatar-text: | ||
spacing: | ||
value: "{size-rem.s}" |
14 changes: 14 additions & 0 deletions
14
packages/docs/src/content/03-components/structure/align/examples/default.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,14 @@ | ||
import { Align } from "@mittwald/flow-react-components/Align"; | ||
import { Avatar } from "@mittwald/flow-react-components/Avatar"; | ||
import { Initials } from "@mittwald/flow-react-components/Initials"; | ||
import { Text } from "@mittwald/flow-react-components/Text"; | ||
|
||
<Align> | ||
<Avatar> | ||
<Initials>Max Mustermann</Initials> | ||
</Avatar> | ||
<Text> | ||
<b>Max Mustermann</b> | ||
Organisationsinhaber | ||
</Text> | ||
</Align>; |
8 changes: 8 additions & 0 deletions
8
packages/docs/src/content/03-components/structure/align/index.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,8 @@ | ||
--- | ||
component: Align | ||
description: | ||
Die Align Komponente dient dazu Komponenten miteinander zu kombinieren | ||
(Momentan nur Avatar + Text). | ||
--- | ||
|
||
<LiveCodeEditor editorDisabled /> |
3 changes: 3 additions & 0 deletions
3
packages/docs/src/content/03-components/structure/align/overview.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,3 @@ | ||
# Avatar + Text | ||
|
||
<LiveCodeEditor /> |