Sha256: 1212a7a66e579e26ee299a9efde48d0cabd470be586e29f1573aa13ff1dd5d7f

Contents?: true

Size: 1.92 KB

Versions: 948

Compression:

Stored size: 1.92 KB

Contents

import React, { useState } from 'react'
import { Dropdown, Icon, Body, FlexItem, Flex, IconCircle } from 'playbook-ui'

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}
          >
            <Flex
                align="center"
                justify="between"
            >
              <FlexItem>
                <Flex>
                  <Icon icon={option.icon} 
                      paddingRight="xs"
                  />
                  <Body text={option.label} />
                </Flex>
              </FlexItem>
              <FlexItem>
                <Body color="light" 
                    text={option.areaCode} 
                />
              </FlexItem>
            </Flex>
          </Dropdown.Option>
        ))}
      </Dropdown.Container>
    </Dropdown>
  </div>
  )
}

export default  DropdownWithCustomTrigger

Version data entries

948 entries across 948 versions & 2 rubygems

Version Path
playbook_ui_docs-14.11.1.pre.alpha.PLAY1720phonenumberinputformatAsYouType5377 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_trigger.jsx
playbook_ui-14.11.1.pre.alpha.PLAY1720phonenumberinputformatAsYouType5377 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_trigger.jsx
playbook_ui_docs-14.11.1.pre.alpha.play17725374 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_trigger.jsx
playbook_ui-14.11.1.pre.alpha.play17725374 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_trigger.jsx
playbook_ui_docs-14.11.1.pre.alpha.play17725372 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_trigger.jsx
playbook_ui-14.11.1.pre.alpha.play17725372 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_trigger.jsx
playbook_ui_docs-14.12.0.pre.rc.4 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_trigger.jsx
playbook_ui-14.12.0.pre.rc.4 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_trigger.jsx
playbook_ui_docs-14.11.1.pre.alpha.hfhbrakemanplaybook5370 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_trigger.jsx
playbook_ui-14.11.1.pre.alpha.hfhbrakemanplaybook5370 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_trigger.jsx
playbook_ui_docs-14.11.1.pre.alpha.responsivetablerails5364 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_trigger.jsx
playbook_ui-14.11.1.pre.alpha.responsivetablerails5364 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_trigger.jsx
playbook_ui_docs-14.11.1.pre.alpha.responsivetablerails5362 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_trigger.jsx
playbook_ui-14.11.1.pre.alpha.responsivetablerails5362 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_trigger.jsx
playbook_ui_docs-14.11.1.pre.alpha.PBNTR769sticky5359 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_trigger.jsx
playbook_ui-14.11.1.pre.alpha.PBNTR769sticky5359 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_trigger.jsx
playbook_ui_docs-14.11.1.pre.alpha.PBNTR573datepickerinvestigation5355 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_trigger.jsx
playbook_ui-14.11.1.pre.alpha.PBNTR573datepickerinvestigation5355 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_trigger.jsx
playbook_ui_docs-14.11.1.pre.alpha.PLAY1750pbcontenttagkitbutton5341 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_trigger.jsx
playbook_ui-14.11.1.pre.alpha.PLAY1750pbcontenttagkitbutton5341 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_trigger.jsx