Sha256: 7940567b87358839ddf1bb01ea2379c881b23e2f814e28a277ae699182312e4d

Contents?: true

Size: 1.83 KB

Versions: 20

Compression:

Stored size: 1.83 KB

Contents

import React, { useState } from 'react'
import { Dropdown, Icon, Body, FlexItem, Flex, IconCircle } from '../..'

const DropdownWithCustomTrigger = (props) => {

const [selectedOption, setSelectedOption] = useState();

  const options = [
    {
      label: "United States",
      value: "United States",
      areaCode: "+1",
      icon: "πŸ‡ΊπŸ‡Έ",
      id: "United-states"
    },
    {
      label: "Canada",
      value: "Canada",
      areaCode: "+1",
      icon: "πŸ‡¨πŸ‡¦",
      id: "canada"
    },
    {
      label: "Pakistan",
      value: "Pakistan",
      areaCode: "+92",
      icon: "πŸ‡΅πŸ‡°",
      id: "pakistan"
    }
  ];  


  return (
  <div>
    <Dropdown
        onSelect={(selectedItem) => setSelectedOption(selectedItem)}
        options={options}
        {...props}
    >
        <Dropdown.Trigger>
            <div key={selectedOption ? selectedOption.icon : "flag"}>
                <IconCircle
                    cursor="pointer"
                    icon={selectedOption ? selectedOption.icon : "flag"}
                    variant="royal"
                />
            </div>
        </Dropdown.Trigger>
      <Dropdown.Container maxWidth="xs">
        {options.map((option) => (
          <Dropdown.Option key={option.id} 
              option={option}
          >
            <>
              <FlexItem>
                <Flex>
                  <Icon icon={option.icon} 
                      paddingRight="xs"
                  />
                  <Body text={option.label} />
                </Flex>
              </FlexItem>
              <FlexItem>
                <Body color="light" 
                    text={option.areaCode} 
                />
              </FlexItem>
            </>
          </Dropdown.Option>
        ))}
      </Dropdown.Container>
    </Dropdown>
  </div>
  )
}

export default  DropdownWithCustomTrigger

Version data entries

20 entries across 20 versions & 2 rubygems

Version Path
playbook_ui_docs-13.27.0 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_trigger.jsx
playbook_ui-13.27.0 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_trigger.jsx
playbook_ui_docs-13.26.0.pre.alpha.PBNTR291Dropdownrailsv22840 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_trigger.jsx
playbook_ui-13.26.0.pre.alpha.PBNTR291Dropdownrailsv22840 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_trigger.jsx
playbook_ui_docs-13.26.0.pre.alpha.jasoncypretpatch12820 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_trigger.jsx
playbook_ui-13.26.0.pre.alpha.jasoncypretpatch12820 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_trigger.jsx
playbook_ui_docs-13.26.0.pre.alpha.jasoncypretpatch12816 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_trigger.jsx
playbook_ui-13.26.0.pre.alpha.jasoncypretpatch12816 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_trigger.jsx
playbook_ui_docs-13.25.0.pre.alpha.PBNTR291Dropdownrailsv22812 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_trigger.jsx
playbook_ui-13.25.0.pre.alpha.PBNTR291Dropdownrailsv22812 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_trigger.jsx
playbook_ui_docs-13.26.0 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_trigger.jsx
playbook_ui-13.26.0 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_trigger.jsx
playbook_ui_docs-13.25.0.pre.alpha.PLAY1249fixTooltipswrappingformelementscausingmisalignment2785 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_trigger.jsx
playbook_ui-13.25.0.pre.alpha.PLAY1249fixTooltipswrappingformelementscausingmisalignment2785 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_trigger.jsx
playbook_ui_docs-13.25.0.pre.alpha.PLAY1249fixTooltipswrappingformelementscausingmisalignment2783 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_trigger.jsx
playbook_ui-13.25.0.pre.alpha.PLAY1249fixTooltipswrappingformelementscausingmisalignment2783 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_trigger.jsx
playbook_ui_docs-13.25.0.pre.alpha.PBNTR272Dropdownkitv42769 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_trigger.jsx
playbook_ui-13.25.0.pre.alpha.PBNTR272Dropdownkitv42769 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_trigger.jsx
playbook_ui_docs-13.25.0.pre.alpha.barchartfix2766 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_trigger.jsx
playbook_ui-13.25.0.pre.alpha.barchartfix2766 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_trigger.jsx