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.11.0.pre.rc.17 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.11.0 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.11.0.pre.rc.16 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.10.0.pre.alpha.play16825301 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.11.0.pre.rc.15 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.11.0.pre.rc.14 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.11.0.pre.rc.13 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.11.0.pre.rc.12 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.10.0.pre.alpha.PLAY1774timelinelabelstepspacing5274 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.10.0.pre.alpha.play1465attempt25272 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.10.0.pre.alpha.play16825244 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.11.0.pre.rc.11 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.11.0.pre.rc.10 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.10.0.pre.alpha.play1662cssbargraph5214 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.10.0.pre.alpha.play1662cssbargraph5213 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.10.0.pre.alpha.play1662cssbargraph5210 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.10.0.pre.alpha.play1662cssbargraph5208 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.10.0.pre.alpha.play1662cssbargraph5207 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.10.0.pre.alpha.play16825206 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.10.0.pre.alpha.play1662cssbargraph5204 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx