All files / packages/design-system/ui/components/pills index.jsx

73.33% Statements 11/15
40% Branches 8/20
50% Functions 4/8
73.33% Lines 11/15

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153          6x 10x                                       9x                         6x 49x                                         6x 19x                       6x 49x               6x                                                                       6x                                                                  
import React from 'react';
import ButtonIcon from '../button-icons/';
import classNames from 'classnames';
import { Tooltip } from '../tooltips/base/example';
 
export let Pill = props => (
  <span className={classNames('slds-pill slds-pill_link', props.className)}>
    {props.children}
    <a
      href="#"
      className="slds-pill__action"
      title={props.label || 'Full pill label verbiage mirrored here'}
      onClick={e => e.preventDefault()}
    >
      <span className="slds-pill__label">{props.label || 'Pill Label'}</span>
    </a>
    <ButtonIcon
      className="slds-button_icon slds-pill__remove"
      symbol="close"
      assistiveText="Remove"
      title="Remove"
    />
  </span>
);
 
export let PillContainer = props => {
  return (
    <div
      className={classNames({
        'slds-pill_container': props.variant !== 'listbox-group',
        'slds-listbox_selection-group': props.variant === 'listbox-group',
        'slds-pill_container_bare': props.variant === 'container-bare'
      })}
    >
      {props.children}
    </div>
  );
};
 
export let ListboxPill = props => (
  <span
    className={classNames('slds-pill', props.className)}
  >
    {props.children}
    <span
      className="slds-pill__label"
      title={props.label || 'Full pill label verbiage mirrored here'}
    >
      {props.label || 'Pill Label'}
    </span>
    <span className="slds-icon_container slds-pill__remove" title="Remove">
      <ButtonIcon
        className="slds-button_icon slds-pill__remove"
        symbol="close"
        assistiveText="Remove"
        title="Remove"
      />
    </span>
  </span>
);
 
export let ListboxPills = props => (
  <ul
    className={classNames(
      'slds-listbox slds-listbox_horizontal',
      props.className
    )}
    aria-label="Selected Options:"
    aria-describedby={props.id}
  >
    {props.children}
  </ul>
);
 
export let ListboxPillsItem = props => (
  <li
    className={classNames('slds-listbox-item', props.className)}
    aria-hidden={props['aria-hidden']}
  >
    {props.children}
  </li>
);
 
export let PillWithTruncation = props => (
  <span
    className={classNames('slds-pill', props.className)}
    tabIndex={props.tabIndex}
    aria-selected="true"
  >
    {props.children}
    <Tooltip
      className="slds-nubbin_bottom-left"
      id="help"
      style={{
        position: 'absolute',
        top: '-45px',
        left: '-2px'
      }}
    >
      {props.label || 'Pill label that is longer than the area that contains it'}
 
    </Tooltip>
    <span
      className="slds-pill__label"
      title={props.label || 'Pill label that is longer than the area that contains it'}
    >
      {props.label || 'Pill label that is longer than the area that contains it'}
    </span>
    <span className="slds-icon_container slds-pill__remove" title="Remove">
      <ButtonIcon
        className="slds-button_icon slds-pill__remove"
        symbol="close"
        assistiveText="Remove"
        title="Remove"
      />
    </span>
  </span>
);
 
export let LinkedPillWithTruncation = props => (
  <span className={classNames('slds-pill slds-pill_link', props.className)}>
    {props.children}
    <Tooltip
      className="slds-nubbin_bottom-left"
      id="help"
      style={{
        position: 'absolute',
        top: '-45px',
        left: '-2px'
      }}
    >
      {props.label || 'Pill label that is longer than the area that contains it'}
 
    </Tooltip>
    <a
      href="#"
      className="slds-pill__action"
      title={props.label || 'Full pill label verbiage mirrored here'}
      onClick={e => e.preventDefault()}
    >
      <span className="slds-pill__label">
        {props.label || 'Pill label that is longer than the area that contains it'}
      </span>
    </a>
    <ButtonIcon
      className="slds-button_icon slds-pill__remove"
      symbol="close"
      assistiveText="Remove"
      title="Remove"
    />
  </span>
);