-
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.
Merge branch 'main' into fix/minor-ui-changes
- Loading branch information
Showing
16 changed files
with
202 additions
and
202 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"packages/dm-core": "1.3.2", | ||
"packages/dm-core-plugins": "1.3.2" | ||
"packages/dm-core": "1.3.3", | ||
"packages/dm-core-plugins": "1.4.0" | ||
} |
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
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,51 @@ | ||
import { Button, Icon, Tooltip } from '@equinor/eds-core-react' | ||
import { IconData } from '@equinor/eds-icons' | ||
import React from 'react' | ||
|
||
type Prefix<T, P extends string> = { | ||
[K in keyof T as `${P}-${string & K}`]: T[K] | ||
} | ||
type PrefixedButton = Prefix< | ||
Omit<React.ComponentProps<typeof Button>, 'aria-label' | 'children'>, | ||
'button' | ||
> | ||
type PrefixedTooltip = Prefix< | ||
Omit<React.ComponentProps<typeof Tooltip>, 'title' | 'children'>, | ||
'tooltip' | ||
> | ||
type TContent = | ||
| { | ||
icon?: IconData | ||
buttonText: string | ||
} | ||
| { | ||
icon: IconData | ||
buttonText?: string | ||
} | ||
type TProps = PrefixedButton & PrefixedTooltip & TContent & { title: string } | ||
|
||
const getProps = (prefix: string, dict: { [k: string]: any }) => { | ||
return Object.fromEntries( | ||
Object.entries(dict) | ||
.filter(([k]) => k.startsWith(prefix)) | ||
.map(([k, v]) => [k.slice(prefix.length), v]) | ||
) | ||
} | ||
|
||
/** | ||
* Tests can access the components through getByRole('button', { name: title })) or getByLabel(title) | ||
* @param props Component accepts all props used by EDS Button and EDS Tooltip. However, to avoid interfering with each other, you'll have to prefix the prop with "button-" or "tooltip-". Ex: button-onChange. In addition, it has a mandatory title prop, which is used both as aria-label and tooltip title. You must also supply it with a buttonText and/or an icon. | ||
* @returns An EDS button with EDS tooltip. | ||
*/ | ||
const TooltipButton = (props: TProps) => { | ||
return ( | ||
<Tooltip title={props.title} {...getProps('tooltip-', props)}> | ||
<Button {...getProps('button-', props)} aria-label={props.title}> | ||
{props.icon && <Icon data={props.icon} />} | ||
{props.buttonText} | ||
</Button> | ||
</Tooltip> | ||
) | ||
} | ||
|
||
export default TooltipButton |
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
Oops, something went wrong.