-
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.
Docs(web-react): Add Dropdown demo #DS-895
Container demo in web-react is now same as demo in web and web-twig
- Loading branch information
1 parent
9b5432c
commit 8d89302
Showing
12 changed files
with
194 additions
and
100 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
packages/web-react/src/components/Dropdown/demo/DropdownContentFactory.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,28 @@ | ||
import React from 'react'; | ||
import { Icon } from '../../Icon'; | ||
|
||
type Props = { | ||
content: Content[]; | ||
}; | ||
|
||
type Content = { | ||
icon: string; | ||
text: string; | ||
}; | ||
|
||
const DropdownContentFactory = ({ content }: Props) => { | ||
const lastRow = content.length - 1; | ||
|
||
return ( | ||
<> | ||
{content.map(({ icon, text }, index) => ( | ||
<a href={`#${icon}`} className={`d-flex ${index !== lastRow && 'mb-400'}`} key={icon}> | ||
<Icon name={icon} UNSAFE_className="mr-400" /> | ||
<span>{text}</span> | ||
</a> | ||
))} | ||
</> | ||
); | ||
}; | ||
|
||
export default DropdownContentFactory; |
22 changes: 22 additions & 0 deletions
22
packages/web-react/src/components/Dropdown/demo/DropdownDefault.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 React, { Ref } from 'react'; | ||
import { DropdownRenderProps } from '../../../types'; | ||
import { Button } from '../../Button'; | ||
import { Dropdown } from '..'; | ||
import DropdownContentFactory from './DropdownContentFactory'; | ||
import { dropdownContent } from './constants'; | ||
|
||
const DropdownDefault = () => { | ||
const dropdownTrigger = ({ trigger: { className, ref, ...restOf } }: DropdownRenderProps) => ( | ||
<Button UNSAFE_className={className} ref={ref as Ref<HTMLButtonElement>} {...restOf}> | ||
Button as anchor | ||
</Button> | ||
); | ||
|
||
return ( | ||
<Dropdown renderTrigger={dropdownTrigger}> | ||
<DropdownContentFactory content={dropdownContent} /> | ||
</Dropdown> | ||
); | ||
}; | ||
|
||
export default DropdownDefault; |
21 changes: 0 additions & 21 deletions
21
packages/web-react/src/components/Dropdown/demo/DropdownDisableAutoClose.tsx
This file was deleted.
Oops, something went wrong.
22 changes: 22 additions & 0 deletions
22
packages/web-react/src/components/Dropdown/demo/DropdownDisabledAutoclose.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 React, { Ref } from 'react'; | ||
import { DropdownRenderProps } from '../../../types'; | ||
import { Button } from '../../Button'; | ||
import { Dropdown } from '..'; | ||
import DropdownContentFactory from './DropdownContentFactory'; | ||
import { dropdownContent } from './constants'; | ||
|
||
const DropdownDisabledAutoclose = () => { | ||
const dropdownTrigger = ({ trigger: { className, ref, ...restOf } }: DropdownRenderProps) => ( | ||
<Button UNSAFE_className={className} ref={ref as Ref<HTMLButtonElement>} {...restOf}> | ||
Button as anchor | ||
</Button> | ||
); | ||
|
||
return ( | ||
<Dropdown renderTrigger={dropdownTrigger} enableAutoClose={false}> | ||
<DropdownContentFactory content={dropdownContent} /> | ||
</Dropdown> | ||
); | ||
}; | ||
|
||
export default DropdownDisabledAutoclose; |
29 changes: 0 additions & 29 deletions
29
packages/web-react/src/components/Dropdown/demo/DropdownFullWidthMode.tsx
This file was deleted.
Oops, something went wrong.
22 changes: 22 additions & 0 deletions
22
packages/web-react/src/components/Dropdown/demo/DropdownFullwidthAll.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 React, { Ref } from 'react'; | ||
import { DropdownRenderProps } from '../../../types'; | ||
import { Button } from '../../Button'; | ||
import { Dropdown } from '..'; | ||
import DropdownContentFactory from './DropdownContentFactory'; | ||
import { dropdownContent } from './constants'; | ||
|
||
const DropdownFullwidthAll = () => { | ||
const dropdownTrigger = ({ trigger: { className, ref, ...restOf } }: DropdownRenderProps) => ( | ||
<Button UNSAFE_className={className} ref={ref as Ref<HTMLButtonElement>} {...restOf}> | ||
Finibus quis imperdiet, semper imperdiet aliquam | ||
</Button> | ||
); | ||
|
||
return ( | ||
<Dropdown renderTrigger={dropdownTrigger} fullWidthMode="all" placement="top-left"> | ||
<DropdownContentFactory content={dropdownContent} /> | ||
</Dropdown> | ||
); | ||
}; | ||
|
||
export default DropdownFullwidthAll; |
22 changes: 22 additions & 0 deletions
22
packages/web-react/src/components/Dropdown/demo/DropdownFullwidthMobileOnly.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 React, { Ref } from 'react'; | ||
import { DropdownRenderProps } from '../../../types'; | ||
import { Button } from '../../Button'; | ||
import { Dropdown } from '..'; | ||
import DropdownContentFactory from './DropdownContentFactory'; | ||
import { dropdownContent } from './constants'; | ||
|
||
const DropdownFullwidthMobileOnly = () => { | ||
const dropdownTrigger = ({ trigger: { className, ref, ...restOf } }: DropdownRenderProps) => ( | ||
<Button UNSAFE_className={className} ref={ref as Ref<HTMLButtonElement>} {...restOf}> | ||
Finibus quis imperdiet, semper imperdiet aliquam | ||
</Button> | ||
); | ||
|
||
return ( | ||
<Dropdown renderTrigger={dropdownTrigger} fullWidthMode="mobile-only" placement="top-left"> | ||
<DropdownContentFactory content={dropdownContent} /> | ||
</Dropdown> | ||
); | ||
}; | ||
|
||
export default DropdownFullwidthMobileOnly; |
22 changes: 22 additions & 0 deletions
22
packages/web-react/src/components/Dropdown/demo/DropdownLongerContent.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 React, { Ref } from 'react'; | ||
import { DropdownRenderProps } from '../../../types'; | ||
import { Button } from '../../Button'; | ||
import { Dropdown } from '..'; | ||
import DropdownContentFactory from './DropdownContentFactory'; | ||
import { dropdownContentLonger } from './constants'; | ||
|
||
const DropdownLongerContent = () => { | ||
const dropdownTrigger = ({ trigger: { className, ref, ...restOf } }: DropdownRenderProps) => ( | ||
<Button UNSAFE_className={className} ref={ref as Ref<HTMLButtonElement>} {...restOf}> | ||
Button as anchor | ||
</Button> | ||
); | ||
|
||
return ( | ||
<Dropdown renderTrigger={dropdownTrigger}> | ||
<DropdownContentFactory content={dropdownContentLonger} /> | ||
</Dropdown> | ||
); | ||
}; | ||
|
||
export default DropdownLongerContent; |
37 changes: 0 additions & 37 deletions
37
packages/web-react/src/components/Dropdown/demo/DropdownPlacements.tsx
This file was deleted.
Oops, something went wrong.
22 changes: 22 additions & 0 deletions
22
packages/web-react/src/components/Dropdown/demo/DropdownTopRight.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 React, { Ref } from 'react'; | ||
import { DropdownRenderProps } from '../../../types'; | ||
import { Button } from '../../Button'; | ||
import { Dropdown } from '..'; | ||
import DropdownContentFactory from './DropdownContentFactory'; | ||
import { dropdownContent } from './constants'; | ||
|
||
const DropdownTopRight = () => { | ||
const dropdownTrigger = ({ trigger: { className, ref, ...restOf } }: DropdownRenderProps) => ( | ||
<Button UNSAFE_className={className} ref={ref as Ref<HTMLButtonElement>} {...restOf}> | ||
Button as anchor | ||
</Button> | ||
); | ||
|
||
return ( | ||
<Dropdown renderTrigger={dropdownTrigger} placement="top-right"> | ||
<DropdownContentFactory content={dropdownContent} /> | ||
</Dropdown> | ||
); | ||
}; | ||
|
||
export default DropdownTopRight; |
13 changes: 13 additions & 0 deletions
13
packages/web-react/src/components/Dropdown/demo/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,13 @@ | ||
export const dropdownContent = [ | ||
{ icon: 'info', text: 'Information' }, | ||
{ icon: 'link', text: 'Bibendum aliquam, fusce integer sit amet congue non nulla aliquet enim' }, | ||
{ icon: 'profile', text: 'Profile' }, | ||
{ icon: 'help', text: 'Help' }, | ||
]; | ||
|
||
export const dropdownContentLonger = [ | ||
{ icon: 'info', text: 'Bibendum aliquam, fusce integer sit amet congue non nulla aliquet enim' }, | ||
{ icon: 'link', text: 'Nulla condimentum, purus commodo cursus non nulla rhoncus' }, | ||
{ icon: 'profile', text: 'Mauris nunc, elementum enim in lacinia vitae quam placerat sem, euismod accumsan' }, | ||
{ icon: 'help', text: 'Donec dui, nunc dui vel varius libero molestie nibh nunc' }, | ||
]; |
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