Skip to content

Commit 66d978f

Browse files
committed
feat: update blue-web to version 1.25.1, add FieldGroup component and usage examples
1 parent 07b6e59 commit 66d978f

6 files changed

Lines changed: 93 additions & 8 deletions

File tree

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
},
3636
"dependencies": {
3737
"@popperjs/core": "^2.11.5",
38-
"blue-web": "^1.23.0",
38+
"blue-web": "^1.25.1",
3939
"bootstrap": "~5.3.3",
4040
"clsx": "^1.1.1"
4141
},

src/components/FieldGroup.tsx

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import clsx from "clsx"
2+
import { ComponentProps, ReactNode } from "react"
3+
4+
export type FieldGroupProps = ComponentProps<"details"> & {
5+
header?: ReactNode
6+
isExpanded?: boolean
7+
headerClassName?: string
8+
id?: string
9+
heading?: number
10+
pageHeader?: boolean
11+
}
12+
13+
export default function FieldGroup({
14+
className,
15+
children,
16+
open,
17+
header,
18+
isExpanded = true,
19+
headerClassName,
20+
id,
21+
heading,
22+
pageHeader,
23+
...rest
24+
}: FieldGroupProps) {
25+
return (
26+
<details
27+
className={clsx("blue-field-group", className)}
28+
open={isExpanded}
29+
{...rest}
30+
>
31+
<summary
32+
role="heading"
33+
aria-level={heading}
34+
className={clsx(headerClassName, {
35+
"blue-page-header w-100 mt-0": pageHeader,
36+
h1: heading === 1,
37+
h2: heading === 2,
38+
h3: heading === 3,
39+
h4: heading === 4,
40+
h5: heading === 5,
41+
h6: heading === 6
42+
})}
43+
>
44+
<svg
45+
xmlns="http://www.w3.org/2000/svg"
46+
width="1em"
47+
height="1em"
48+
fill="currentColor"
49+
aria-hidden="true"
50+
className="blue-field-group-chevron bi bi-chevron-right fs-6 opacity-50"
51+
viewBox="0 0 16 16"
52+
>
53+
<path
54+
fillRule="evenodd"
55+
d="M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708"
56+
/>
57+
</svg>
58+
{header}
59+
{id !== undefined && id !== null && id !== "" && (
60+
<small className="text-secondary ms-1">{id}</small>
61+
)}
62+
</summary>
63+
{children}
64+
</details>
65+
)
66+
}

src/docs/App.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ import {
1717
App as AppIcon,
1818
Search,
1919
Window,
20-
PlayBtn
20+
PlayBtn,
21+
CardHeading
2122
} from "react-bootstrap-icons"
2223

2324
import { ComponentPage } from "./pages/ComponentPage"
@@ -235,6 +236,9 @@ function App() {
235236
case "Button":
236237
icon = <PlayBtn />
237238
break
239+
case "FieldGroup":
240+
icon = <CardHeading />
241+
break
238242
default:
239243
icon = <FileCode />
240244
}
@@ -250,8 +254,7 @@ function App() {
250254
buttonContent={
251255
comp.displayName &&
252256
([
253-
"Actions",
254-
"MenuItem"
257+
"FieldGroup"
255258
].includes(
256259
comp.displayName
257260
) ? (
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import FieldGroup from "../../../components/FieldGroup"
2+
3+
export default function FieldGroupBasicUsage() {
4+
return (
5+
<FieldGroup header="Field group 1">Content of field group 1</FieldGroup>
6+
)
7+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import FieldGroup from "../../../components/FieldGroup"
2+
3+
export default function FieldGroupHeadings() {
4+
return (
5+
<FieldGroup header="Field group 1" pageHeader heading={2}>
6+
Content of field group 1
7+
</FieldGroup>
8+
)
9+
}

0 commit comments

Comments
 (0)