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.1.pre.alpha.PLAY1720phonenumberinputformatAsYouType5377 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.11.1.pre.alpha.play17725374 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.11.1.pre.alpha.play17725372 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.12.0.pre.rc.4 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.11.1.pre.alpha.hfhbrakemanplaybook5370 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.11.1.pre.alpha.responsivetablerails5364 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.11.1.pre.alpha.responsivetablerails5362 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.11.1.pre.alpha.PBNTR769sticky5359 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.11.1.pre.alpha.PBNTR573datepickerinvestigation5355 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.11.1.pre.alpha.PLAY1750pbcontenttagkitbutton5341 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.11.1.pre.alpha.PLAY1750pbcontenttagkitbutton5340 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.11.1.pre.alpha.PLAY1750pbcontenttagkitbutton5339 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.12.0.pre.rc.3 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.12.0.pre.rc.2 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.12.0.pre.rc.1 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.12.0.pre.rc.0 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.10.0.pre.alpha.PLAY1774timelinelabelstepspacing5315 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.10.0.pre.alpha.PLAY1774timelinelabelstepspacing5314 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.10.0.pre.alpha.PLAY1750pbcontenttagkitbutton5308 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.11.1 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx