Sha256: 627dae0ea819ec750bf10b694871d759c4c3ee36a5241982fb0f1cb0c80e594e

Contents?: true

Size: 1.65 KB

Versions: 948

Compression:

Stored size: 1.65 KB

Contents

import React, { useRef } from 'react'
import { Dropdown, useDropdown, CircleIconButton, Icon, Body, FlexItem, Flex  } from 'playbook-ui'

const DropdownWithHook = (props) => {
const [isDropDownClosed, setIsDropdownClosed] = useDropdown(true);
const buttonRef = useRef(null);

  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>
      <CircleIconButton
          htmlOptions={{ref: buttonRef}}
          icon={"flag"}
          onClick={() => setIsDropdownClosed(!isDropDownClosed)}
          variant="secondary"
      />
    <Dropdown
        isClosed={isDropDownClosed}
        options={options}
        triggerRef={buttonRef}
        {...props}
    >
      {options.map((option) => (
        <Dropdown.Option key={option.id} 
            option={option}
        > 
        <>
          <FlexItem>
              <Flex paddingRight='md'>
                <Icon icon={option.icon} 
                    paddingRight="xs"
                />
                <Body text={option.label} />
              </Flex>
          </FlexItem>
              <FlexItem>
                <Body color="light" 
                    text={option.areaCode} 
                />
              </FlexItem>
            </>
        </Dropdown.Option>
      ))}
    </Dropdown>
  </div>
  )
}

export default DropdownWithHook

Version data entries

948 entries across 948 versions & 2 rubygems

Version Path
playbook_ui_docs-14.11.1.pre.alpha.PLAY1750pbcontenttagkitbutton5340 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_hook.jsx
playbook_ui-14.11.1.pre.alpha.PLAY1750pbcontenttagkitbutton5340 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_hook.jsx
playbook_ui_docs-14.11.1.pre.alpha.PLAY1750pbcontenttagkitbutton5339 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_hook.jsx
playbook_ui-14.11.1.pre.alpha.PLAY1750pbcontenttagkitbutton5339 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_hook.jsx
playbook_ui_docs-14.12.0.pre.rc.3 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_hook.jsx
playbook_ui-14.12.0.pre.rc.3 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_hook.jsx
playbook_ui_docs-14.12.0.pre.rc.2 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_hook.jsx
playbook_ui-14.12.0.pre.rc.2 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_hook.jsx
playbook_ui_docs-14.12.0.pre.rc.1 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_hook.jsx
playbook_ui-14.12.0.pre.rc.1 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_hook.jsx
playbook_ui_docs-14.12.0.pre.rc.0 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_hook.jsx
playbook_ui-14.12.0.pre.rc.0 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_hook.jsx
playbook_ui_docs-14.10.0.pre.alpha.PLAY1774timelinelabelstepspacing5315 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_hook.jsx
playbook_ui-14.10.0.pre.alpha.PLAY1774timelinelabelstepspacing5315 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_hook.jsx
playbook_ui_docs-14.10.0.pre.alpha.PLAY1774timelinelabelstepspacing5314 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_hook.jsx
playbook_ui-14.10.0.pre.alpha.PLAY1774timelinelabelstepspacing5314 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_hook.jsx
playbook_ui_docs-14.10.0.pre.alpha.PLAY1750pbcontenttagkitbutton5308 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_hook.jsx
playbook_ui-14.10.0.pre.alpha.PLAY1750pbcontenttagkitbutton5308 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_hook.jsx
playbook_ui-14.11.1 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_hook.jsx
playbook_ui_docs-14.11.0.pre.rc.17 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_hook.jsx