-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Jeroen Branje <[email protected]>
- Loading branch information
1 parent
b7caf64
commit 943d662
Showing
21 changed files
with
318 additions
and
137 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
...esign-system/src/components/Atoms/IconButtonWithTooltip/IconButtonWithTooltip.stories.tsx
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,23 @@ | ||
import { Meta, Story } from '@storybook/react' | ||
import React from 'react' | ||
|
||
import IconButtonWithTooltip from './IconButtonWithTooltip' | ||
|
||
export default { | ||
component: IconButtonWithTooltip, | ||
title: 'Components/IconButtonWithTooltip', | ||
} as Meta | ||
|
||
const Template: Story = ({ icon, onClick, description }) => ( | ||
<IconButtonWithTooltip icon={icon} onClick={() => onClick()}> | ||
{description} | ||
</IconButtonWithTooltip> | ||
) | ||
|
||
export const IconButtonWithTooltipStory = Template.bind({}) | ||
|
||
IconButtonWithTooltipStory.args = { | ||
icon: <span>ICON</span>, | ||
onClick: () => console.log('action'), | ||
description: 'Tooltip content', | ||
} |
47 changes: 47 additions & 0 deletions
47
apps/design-system/src/components/Atoms/IconButtonWithTooltip/IconButtonWithTooltip.tsx
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,47 @@ | ||
import React, { FC, ReactNode, useState } from 'react' | ||
|
||
import { TooltipType } from '../../../types' | ||
|
||
interface Props { | ||
icon: JSX.Element | ||
type?: TooltipType | ||
children: ReactNode | ||
disabled?: boolean | ||
onClick: () => void | ||
} | ||
|
||
const IconButtonWithTooltip: FC<Props> = ({ icon, children, disabled = false, onClick }) => { | ||
const [hover, setHover] = useState(false) | ||
|
||
const handleMouseIn = () => !disabled && setHover(true) | ||
|
||
const handleMouseOut = () => !disabled && setHover(false) | ||
|
||
const styles = hover ? 'opacity-100 visible duration-100' : 'delay-300 opacity-0 invisible' | ||
|
||
return ( | ||
<div className="relative flex items-center justify-center"> | ||
<button | ||
onMouseOver={handleMouseIn} | ||
onMouseOut={handleMouseOut} | ||
onFocus={handleMouseIn} | ||
onBlur={handleMouseOut} | ||
disabled={disabled} | ||
type="button" | ||
onClick={() => !disabled && onClick()} | ||
className={`inline-flex items-center text-gray-600 hover:text-gray-800 text-sm font-semibold disabled:cursor-not-allowed disabled:text-gray-400 disabled:hover:text-gray-400`} | ||
> | ||
{icon} | ||
</button> | ||
<div | ||
role="tooltip" | ||
className={`${styles} flex justify-center absolute z-30 bottom-full py-2 px-3 text-xs font-medium rounded-lg shadow-lg tracking-wide text-white bg-gray-700 transition mb-3 border border-gray-600`} | ||
> | ||
{children} | ||
<div className="block w-3 h-3 bg-gray-700 absolute -bottom-1.5 mx-auto transform rotate-45 z-0 border-r border-b border-gray-600" /> | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
export default IconButtonWithTooltip |
22 changes: 22 additions & 0 deletions
22
...esign-system/src/components/Atoms/IconButtonWithTooltip/IconButtonWithTooltip.ui.test.tsx
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,22 @@ | ||
import { render, screen } from '@testing-library/react' | ||
import React from 'react' | ||
|
||
import IconButtonWithTooltip from './IconButtonWithTooltip' | ||
|
||
describe('atoms/IconButtonWithTooltip', () => { | ||
describe('render', () => { | ||
it('should render IconButtonWithTooltip with content', () => { | ||
const content = 'Tooltip content' | ||
// when ... rendering component | ||
render( | ||
<IconButtonWithTooltip icon={<span>Button</span>} onClick={() => {}}> | ||
{content} | ||
</IconButtonWithTooltip>, | ||
) | ||
const IconButtonWithTooltipElement = screen.getByText(content) | ||
|
||
// then ... should render as expected | ||
expect(IconButtonWithTooltipElement).toBeInTheDocument() | ||
}) | ||
}) | ||
}) |
1 change: 1 addition & 0 deletions
1
apps/design-system/src/components/Atoms/IconButtonWithTooltip/index.ts
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 @@ | ||
export { default as IconButtonWithTooltip } from './IconButtonWithTooltip' |
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
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
9 changes: 9 additions & 0 deletions
9
apps/envited.ascs.digital/modules/UploadedAsset/UploadAsset.constants.ts
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,9 @@ | ||
import { AssetAction, AssetStatus } from '../../common/types' | ||
|
||
export const enabledActionsMap = { | ||
[AssetStatus.processing]: [], | ||
[AssetStatus.rejected]: [AssetAction.delete], | ||
[AssetStatus.minted]: [AssetAction.view], | ||
[AssetStatus.completed]: [AssetAction.view], | ||
[AssetStatus.pending]: [AssetAction.mint, AssetAction.delete], | ||
} |
Oops, something went wrong.