Skip to content

Commit 2e7cc32

Browse files
committed
✨ Add Group component
1 parent 94b84e5 commit 2e7cc32

File tree

9 files changed

+379
-2
lines changed

9 files changed

+379
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ import { Accordion } from 'webcoreui/react'
203203
- [Checkbox](https://github.com/Frontendland/webcoreui/tree/main/src/components/Checkbox)
204204
- [Collapsible](https://github.com/Frontendland/webcoreui/tree/main/src/components/Collapsible)
205205
- [ConditionalWrapper](https://github.com/Frontendland/webcoreui/tree/main/src/components/ConditionalWrapper)
206+
- [Group](https://github.com/Frontendland/webcoreui/tree/main/src/components/Group)
206207
- [Icon](https://github.com/Frontendland/webcoreui/tree/main/src/components/Icon)
207208
- [Input](https://github.com/Frontendland/webcoreui/tree/main/src/components/Input)
208209
- [List](https://github.com/Frontendland/webcoreui/tree/main/src/components/List)

scripts/createComponent.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const templates = {
2424
astro: `
2525
---
2626
import type { ${component}Props } from './${lowerCaseComponent}'
27+
2728
import styles from './${lowerCaseComponent}.module.scss'
2829
2930
interface Props extends ${component}Props {}
@@ -89,8 +90,8 @@ const templates = {
8990
`,
9091
page: `
9192
---
92-
import Layout from '@static/Layout.astro'
9393
import ComponentWrapper from '@static/ComponentWrapper.astro'
94+
import Layout from '@static/Layout.astro'
9495
9596
import Astro${component} from '@components/${component}/${component}.astro'
9697
import Svelte${component} from '@components/${component}/${component}.svelte'

src/components/Button/button.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ export type SvelteButtonProps = {
1818

1919
export type ReactButtonProps = {
2020
onClick?: () => any
21-
children?: React.ReactNode
21+
children: React.ReactNode
2222
} & ButtonProps

src/components/Group/Group.astro

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
import type { GroupProps } from './group'
3+
4+
import styles from './group.module.scss'
5+
6+
interface Props extends GroupProps {}
7+
8+
const {
9+
withSeparator,
10+
outline,
11+
className
12+
} = Astro.props
13+
14+
const classes = [
15+
styles.group,
16+
withSeparator && styles.separator,
17+
outline && styles.outline,
18+
className
19+
]
20+
---
21+
22+
<div class:list={classes}>
23+
<slot />
24+
</div>

src/components/Group/Group.svelte

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<script lang="ts">
2+
import type { GroupProps } from './group'
3+
4+
import { classNames } from '../../utils/classNames'
5+
6+
import styles from './group.module.scss'
7+
8+
export let withSeparator: GroupProps['withSeparator'] = false
9+
export let outline: GroupProps['outline'] = false
10+
export let className: GroupProps['className'] = ''
11+
12+
const classes = classNames([
13+
styles.group,
14+
withSeparator && styles.separator,
15+
outline && styles.outline,
16+
className
17+
])
18+
</script>
19+
20+
<div class={classes}>
21+
<slot />
22+
</div>

src/components/Group/Group.tsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import React from 'react'
2+
import type { ReactGroupProps } from './group'
3+
4+
import { classNames } from '../../utils/classNames'
5+
6+
import styles from './group.module.scss'
7+
8+
const Group = ({
9+
withSeparator,
10+
outline,
11+
className,
12+
children
13+
}: ReactGroupProps) => {
14+
const classes = classNames([
15+
styles.group,
16+
withSeparator && styles.separator,
17+
outline && styles.outline,
18+
className
19+
])
20+
21+
return <div className={classes}>{children}</div>
22+
}
23+
24+
export default Group
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
@import '../../scss/config.scss';
2+
3+
.group {
4+
@include layout(flex, none);
5+
6+
button,
7+
span {
8+
@include border-radius(none);
9+
10+
&:first-child {
11+
@include border-radius(left, md);
12+
}
13+
14+
&:last-child {
15+
@include border-radius(right, md);
16+
}
17+
}
18+
19+
&.separator button,
20+
&.separator span {
21+
@include border(1px, primary-70);
22+
23+
&:first-child {
24+
@include border(right, 0);
25+
}
26+
27+
&:last-child {
28+
@include border(left, 0);
29+
}
30+
}
31+
32+
&.outline button
33+
&.outline span {
34+
@include border(1px, primary-20);
35+
box-shadow: none;
36+
37+
&:hover {
38+
@include border(1px, primary);
39+
box-shadow: none;
40+
}
41+
42+
&:first-child {
43+
@include border(right, 0);
44+
}
45+
46+
&:last-child {
47+
@include border(left, 0);
48+
}
49+
}
50+
}

src/components/Group/group.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export type GroupProps = {
2+
withSeparator?: boolean
3+
outline?: boolean
4+
className?: string
5+
}
6+
7+
export type ReactGroupProps = {
8+
children: React.ReactNode
9+
} & GroupProps

0 commit comments

Comments
 (0)