Sha256: df66607b4b8e3440fb7831d03f76bbc9d4c9fd2bbd7bf13038c0dba8782c6d5c

Contents?: true

Size: 1.83 KB

Versions: 863

Compression:

Stored size: 1.83 KB

Contents

import React from 'react'
import { isEmpty, map, omitBy } from 'lodash'

import Body from '../../pb_body/_body'
import Caption from '../../pb_caption/_caption'
import Title from '../../pb_title/_title'

export type FilterDescription = {
  [key: string]: string | null | boolean,
}

export type CurrentFiltersProps = {
  dark: boolean,
  filters: FilterDescription,
}

const hiddenFilters = (value: any) => isEmpty(value) && value !== true

const CurrentFilters = ({ dark, filters }: CurrentFiltersProps): React.ReactElement => {
  const displayableFilters = omitBy(filters, hiddenFilters)

  return (
    <div className="maskContainer">
      { isEmpty(filters) &&
      <div className="filters">
        <Body
            color="light"
            paddingLeft="xs"
            size={4}
            tag="span"
            text="No Filter Selected"
        />
      </div>
      }
      { !isEmpty(filters) &&
        <div className="filters">
          <div className="left_gradient" />
            {map(displayableFilters, (value, name) => (
              <div
                  className="filter"
                  key={`filter-${name}`}
              >
                { value === true ? 
                <Title
                    dark={dark}
                    size={4}
                    tag="h4"
                    text={name}
                /> : 
                <div>
                  <Caption
                      dark={dark}
                      text={name}
                  />
                  <Title
                      dark={dark}
                      size={4}
                      tag="h4"
                      text={value}
                  />
                </div>    
                }
              </div>
            ))}
          <div className="right_gradient" />
        </div>
      }
    </div>
  )
}

export default CurrentFilters

Version data entries

863 entries across 863 versions & 1 rubygems

Version Path
playbook_ui-12.23.0.pre.alpha.play698responsivespacingglobalprop701 app/pb_kits/playbook/pb_filter/Filter/CurrentFilters.tsx
playbook_ui-12.23.0 app/pb_kits/playbook/pb_filter/Filter/CurrentFilters.tsx
playbook_ui-12.22.0.pre.alpha.PBNTR12checkingemptyfilters686 app/pb_kits/playbook/pb_filter/Filter/CurrentFilters.tsx