Sha256: e4ebd8227d88526c9bf2e76b62c44ae600ece7ec19ca7d73ccd3b8321f67f4ce

Contents?: true

Size: 1.64 KB

Versions: 100

Compression:

Stored size: 1.64 KB

Contents

import React, { useRef } from 'react'
import { Dropdown, useDropdown, CircleIconButton, Icon, Body, FlexItem, Flex  } from '../..'

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

100 entries across 100 versions & 2 rubygems

Version Path
playbook_ui_docs-13.34.1.pre.alpha.play1407statvaluekitinconsistencies3388 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_hook.jsx
playbook_ui-13.34.1.pre.alpha.play1407statvaluekitinconsistencies3388 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_hook.jsx
playbook_ui_docs-13.34.1.pre.alpha.PLAY14703378 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_hook.jsx
playbook_ui-13.34.1.pre.alpha.PLAY14703378 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_hook.jsx
playbook_ui_docs-13.34.1 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_hook.jsx
playbook_ui-13.34.1 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_hook.jsx
playbook_ui_docs-13.34.0.pre.alpha.PBNTR358responsiveadvancedtablereact3370 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_hook.jsx
playbook_ui-13.34.0.pre.alpha.PBNTR358responsiveadvancedtablereact3370 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_hook.jsx
playbook_ui_docs-13.34.0.pre.alpha.PBNTR358responsiveadvancedtablereact3369 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_hook.jsx
playbook_ui-13.34.0.pre.alpha.PBNTR358responsiveadvancedtablereact3369 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_hook.jsx
playbook_ui-13.34.0.pre.alpha.PBNTR358responsiveadvancedtablereact3368 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_hook.jsx
playbook_ui_docs-13.34.0.pre.alpha.PBNTR358responsiveadvancedtablereact3366 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_hook.jsx
playbook_ui-13.34.0.pre.alpha.PBNTR358responsiveadvancedtablereact3366 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_hook.jsx
playbook_ui-13.34.0 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_hook.jsx
playbook_ui_docs-13.33.1.pre.alpha.play1407statvaluekitinconsistencies3352 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_hook.jsx
playbook_ui-13.33.1.pre.alpha.play1407statvaluekitinconsistencies3352 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_hook.jsx
playbook_ui_docs-13.33.1.pre.alpha.PLAY14063320 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_hook.jsx
playbook_ui-13.33.1.pre.alpha.PLAY14063320 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_hook.jsx
playbook_ui-13.33.1 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_hook.jsx
playbook_ui_docs-13.33.0.pre.alpha.PBNTR405dropdownformfixesrails3311 app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_hook.jsx