generated from nl-design-system/example
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Token changes: - todo-toggletip-* tokens renamed to rhc-toggletip-* --------- Co-authored-by: Ruben Smit <[email protected]>
- Loading branch information
Showing
10 changed files
with
182 additions
and
8 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 |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/** | ||
* @license EUPL-1.2 | ||
* Copyright (c) 2021 Community for NL Design System | ||
*/ | ||
|
||
@mixin rhc-toggletip { | ||
background-color: transparent; | ||
border-radius: var(--rhc-toggletip-border-radius); | ||
display: inline-flex; | ||
flex-direction: column; | ||
size: var(--rhc-toggletip-size); | ||
} | ||
|
||
@mixin rhc-toggletip__summary { | ||
cursor: pointer; | ||
display: inline-flex; | ||
margin-block-end: var(--rhc-toggletip-gap, 16px); | ||
max-inline-size: var(--rhc-toggletip-size); | ||
size: var(--rhc-toggletip-size); | ||
} | ||
|
||
@mixin rhc-toggletip__button { | ||
background-color: var(--rhc-toggletip-background-color); | ||
border-color: var(--rhc-toggletip-border-color); | ||
border-radius: var(--rhc-toggletip-border-radius); | ||
border-width: var(--rhc-toggletip-border-width); | ||
color: var(--rhc-toggletip-color); | ||
cursor: pointer; | ||
display: inline-flex; | ||
max-inline-size: var(--rhc-toggletip-size); | ||
padding-block: 0; | ||
padding-inline: 0; | ||
size: var(--rhc-toggletip-size); | ||
} | ||
|
||
@mixin rhc-toggletip__button--no-pointer-events { | ||
pointer-events: none; | ||
} | ||
|
||
@mixin rhc-toggletip__icon { | ||
size: var(--rhc-toggletip-icon-size); | ||
} | ||
|
||
@mixin rhc-toggletip--active { | ||
background-color: var(--rhc-toggletip-active-background-color); | ||
border-color: var(--rhc-toggletip-active-border-color); | ||
border-style: solid; | ||
color: var(--rhc-toggletip-active-color); | ||
} | ||
|
||
@mixin rhc-toggletip--hover { | ||
background-color: var(--rhc-toggletip-hover-background-color); | ||
color: var(--rhc-toggletip-hover-color); | ||
} | ||
|
||
@mixin rhc-toggletip--focus { | ||
background-color: var(--rhc-toggletip-focus-background-color); | ||
color: var(--rhc-toggletip-focus-color); | ||
} |
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,48 @@ | ||
/** | ||
* @license EUPL-1.2 | ||
* Copyright (c) 2021 Community for NL Design System | ||
*/ | ||
|
||
@import "./mixin"; | ||
|
||
.rhc-toggletip { | ||
@include rhc-toggletip; | ||
} | ||
|
||
.rhc-toggletip__summary { | ||
@include rhc-toggletip__summary; | ||
} | ||
|
||
.rhc-toggletip__button { | ||
@include rhc-toggletip__button; | ||
} | ||
|
||
.rhc-toggletip__summary .rhc-toggletip__button { | ||
// If button is not used standalone the summary should take precedence | ||
@include rhc-toggletip__button--no-pointer-events; | ||
} | ||
|
||
.rhc-toggletip__button:focus { | ||
@include rhc-toggletip--focus; | ||
} | ||
|
||
.rhc-toggletip__button:hover { | ||
@include rhc-toggletip--hover; | ||
} | ||
|
||
.rhc-toggletip__summary:focus .rhc-toggletip__button { | ||
@include rhc-toggletip--focus; | ||
} | ||
|
||
.rhc-toggletip__summary:hover .rhc-toggletip__button { | ||
@include rhc-toggletip--hover; | ||
} | ||
|
||
.rhc-toggletip:active .rhc-toggletip__button, | ||
.rhc-toggletip[open] .rhc-toggletip__button { | ||
@include rhc-toggletip--active; | ||
} | ||
|
||
.rhc-toggletip__icon { | ||
@include rhc-toggletip__icon; | ||
} |
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,46 @@ | ||
import clsx from 'clsx'; | ||
import { DetailsHTMLAttributes, ForwardedRef, forwardRef, PropsWithChildren, ReactNode } from 'react'; | ||
import { Alert } from './Alert'; | ||
import { Icon } from './icon/Icon'; | ||
|
||
export interface ToggletipProps extends DetailsHTMLAttributes<HTMLDetailsElement> { | ||
className?: string; | ||
} | ||
|
||
export const ToggletipButton = forwardRef( | ||
({ children }: { children?: ReactNode }, ref: ForwardedRef<HTMLButtonElement>) => { | ||
return ( | ||
<button className="rhc-toggletip__button" ref={ref}> | ||
<Icon className="rhc-toggletip__icon" icon="info" /> | ||
{children} | ||
</button> | ||
); | ||
}, | ||
); | ||
ToggletipButton.displayName = 'ToggletipButton'; | ||
|
||
export const ToggletipContent = forwardRef( | ||
({ children }: { children: ReactNode }, ref: ForwardedRef<HTMLDivElement>) => { | ||
return ( | ||
<div className="rhc-toggletip__content" ref={ref}> | ||
<Alert type="info">{children}</Alert> | ||
</div> | ||
); | ||
}, | ||
); | ||
ToggletipContent.displayName = 'ToggletipContent'; | ||
|
||
export const Toggletip = forwardRef( | ||
({ children, className, ...restProps }: PropsWithChildren<ToggletipProps>, ref: ForwardedRef<HTMLDetailsElement>) => { | ||
return ( | ||
<details className={clsx('rhc-toggletip', className)} ref={ref} {...restProps}> | ||
<summary className="rhc-toggletip__summary"> | ||
<ToggletipButton /> | ||
</summary> | ||
<ToggletipContent>{children}</ToggletipContent> | ||
</details> | ||
); | ||
}, | ||
); | ||
|
||
Toggletip.displayName = 'Toggletip'; |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Toggletip } from '@rijkshuisstijl-community/components-react'; | ||
import { Meta, StoryObj } from '@storybook/react'; | ||
|
||
const meta = { | ||
title: 'Rijkshuisstijl/Toggletip', | ||
id: 'rhc-toggletip', | ||
component: Toggletip, | ||
args: { | ||
children: 'Lorem ipsum dolor sit amet, consecteur ad * isicing elit, sed do eiusmod *', | ||
}, | ||
} satisfies Meta<typeof Toggletip>; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Default: Story = {}; |
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