Sha256: 8954065759585ecff5603b24cbedd67214ff0cd50f263a23e192441c8972c223

Contents?: true

Size: 1.3 KB

Versions: 252

Compression:

Stored size: 1.3 KB

Contents

import React from 'react'

import Caption from '../../pb_caption/_caption'
import TitleCount from '../../pb_title_count/_title_count'

const resultsText = (results: number): string => results == 1 ? 'Result' : 'Results'

type ResultsCountProps = {
  dark?: boolean,
  results?: number | null,
  title?: boolean,
}
const ResultsCount = ({ dark, results, title }: ResultsCountProps): React.ReactElement => {
  
  const resultTitle = () => {
    if (results == null) return null
    return (
      <TitleCount
          align="center"
          count={results}
          dark={dark}
          title={`${resultsText(results)}:`}
      />
    )
  }

  const justResults = () => {
    if (results == null) return null
    return (
      <Caption
          className="filter-results"
          dark={dark}
          size="xs"
          text={`${results} ${resultsText(results)}`}
      />
    )
  }

  const displayResultsCount = () => {
    if (results != null && results >=0 && title) {
      return (
        <>
          {resultTitle()}
        </>
      )
    } else if (results !=null && results >=0 ) {
      return (
        <>
          {justResults()}
        </>
      )
    } else {
      return (
        <div />
      )
    }
  }
  
  return (
    <>
      {displayResultsCount()}
    </>
  )
}

export default ResultsCount

Version data entries

252 entries across 252 versions & 1 rubygems

Version Path
playbook_ui-14.6.2.pre.alpha.PBNTR633dropdownavailablepropstable4305 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.7.0.pre.rc.6 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.6.2.pre.alpha.PBNTR576tooltiptruncatedformpills4304 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.6.2.pre.alpha.PBNTR633dropdownavailablepropstable4303 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.6.2.pre.alpha.PBNTR576tooltiptruncatedformpills4296 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.6.2.pre.alpha.PLAY1550lazysizesupgrade4295 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.6.2.pre.alpha.PLAY1485selectablecardoverflowoutlinebug4274 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.6.2.pre.alpha.PLAY1607dependencydisplayymlupdate4271 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.6.2.pre.alpha.PLAY1538READMEroot4262 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.6.2.pre.alpha.PLAY1538READMEroot4260 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.6.2.pre.alpha.PLAY1550lazysizesupgrade4257 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.6.2.pre.alpha.PLAY1538READMEroot4254 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.6.2.pre.alpha.PLAY1538READMEroot4251 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.7.0.pre.rc.5 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.6.2.pre.alpha.PLAY1485selectablecardoverflowoutlinebug4247 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.7.0.pre.rc.4 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.7.0.pre.rc.3 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.6.2 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.7.0.pre.rc.2 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.6.0.pre.alpha.dropdownclassfix4224 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx