-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: add slider and radio control renderers (#4394)
* docs: allow override of default control renderer, add slider * docs: add radio group control renderer * docs: minor changes and Banner page
- Loading branch information
Showing
6 changed files
with
230 additions
and
49 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,5 +5,6 @@ export default { | |
}, | ||
avatar: "Avatar", | ||
badge: "Badge", | ||
banner: "Banner", | ||
button: "Button", | ||
}; |
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,125 @@ | ||
import { css } from "@emotion/css"; | ||
import { bannerClasses, HvBanner } from "@hitachivantara/uikit-react-core"; | ||
|
||
import { Description } from "@docs/components/Description"; | ||
import { Page } from "@docs/components/Page"; | ||
|
||
import Playground from "./Playground"; | ||
|
||
import { getComponentData } from "../../utils/utils"; | ||
|
||
export const getStaticProps = async ({ params }) => { | ||
const meta = await getComponentData("Banner", "core", bannerClasses); | ||
return { props: { ssg: { meta: meta } } }; | ||
}; | ||
|
||
<Description /> | ||
|
||
<Page> | ||
|
||
<Playground | ||
Component={HvBanner} | ||
componentName="HvBanner" | ||
controls={{ | ||
variant: { | ||
defaultValue: "default", | ||
}, | ||
showIcon: { | ||
defaultValue: true, | ||
}, | ||
}} | ||
componentProps={{ | ||
open: true, | ||
label: "This is an informational message.", | ||
style: { position: "relative", top: 0 }, | ||
}} | ||
/> | ||
|
||
### Aactions | ||
|
||
You can add a set of actions to the banner by specifying the `actions` prop. The `onAction` prop is a callback function that is called when an action is clicked. | ||
|
||
```jsx live | ||
<HvBanner | ||
open | ||
offset={0} | ||
label="This is a banner." | ||
showIcon | ||
actions={[ | ||
{ id: "action_1", label: "Action 1", disabled: false }, | ||
{ id: "action_2", label: "Action 2", disabled: false }, | ||
]} | ||
onAction={(event, action) => console.log("Clicked", action)} | ||
style={{ position: "relative", top: 0 }} | ||
/> | ||
``` | ||
|
||
### Custom icons | ||
|
||
You can pass a custom icon to the banner by using the `customIcon` prop. | ||
|
||
```jsx live | ||
<HvBanner | ||
open | ||
offset={0} | ||
label="This is a banner with a custom icon." | ||
customIcon={<LightOn color="base_dark" />} | ||
style={{ position: "relative", top: 0 }} | ||
/> | ||
``` | ||
|
||
### Controlled | ||
|
||
Controlled banner. Click the buttons to display different banners. | ||
|
||
```jsx live | ||
import { useState } from "react"; | ||
|
||
export default function Demo() { | ||
const SimpleBanner = ({ | ||
variant, | ||
...others | ||
}: Omit<HvBannerProps, "open">) => { | ||
const [open, setOpen] = useState(false); | ||
|
||
return ( | ||
<> | ||
<HvButton | ||
onClick={() => setOpen(true)} | ||
color="primary" | ||
style={{ width: "150px", textTransform: "capitalize", margin: 10 }} | ||
> | ||
{variant} | ||
</HvButton> | ||
<HvBanner | ||
open={open} | ||
onClose={() => setOpen(false)} | ||
offset={10} | ||
variant={variant} | ||
showIcon | ||
actions={ | ||
<HvButton variant="secondaryGhost" style={{ color: "inherit" }}> | ||
Action | ||
</HvButton> | ||
} | ||
bannerContentProps={{ | ||
actionProps: { "aria-label": "Close the banner" }, | ||
}} | ||
{...others} | ||
/> | ||
</> | ||
); | ||
}; | ||
|
||
return ( | ||
<> | ||
<SimpleBanner variant="default" label="This is a banner." /> | ||
<SimpleBanner variant="success" label="This is a success banner." /> | ||
<SimpleBanner variant="error" label="This is an error banner." /> | ||
</> | ||
); | ||
|
||
} | ||
``` | ||
|
||
</Page> |
Oops, something went wrong.