Sha256: 1dec11eacdc95e92c0890ccaf31f9912891a008a5239dd0397e9bbb6a99b4bac

Contents?: true

Size: 1.18 KB

Versions: 691

Compression:

Stored size: 1.18 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 = () => {
    return (
      <TitleCount
          align="center"
          count={results}
          dark={dark}
          title={`${resultsText(results)}:`}
      />
    )
  }

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

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

export default ResultsCount

Version data entries

691 entries across 691 versions & 1 rubygems

Version Path
playbook_ui-14.5.0.pre.alpha.PLAY1548intltelinputupdatelatest4077 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.6.0.pre.rc.14 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.5.0.pre.alpha.PLAY1548intltelinputupdatelatest4073 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.5.0.pre.alpha.PLAY15814066 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.5.0.pre.alpha.PBNTR568dropdowncleaning4044 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.5.0.pre.alpha.PBNTR568dropdowncleaning4041 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.5.0.pre.alpha.PLAY15814040 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.6.0.pre.rc.13 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.5.0.pre.alpha.PLAY1548intltelinputupdatelatest4037 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.5.0.pre.alpha.20241007playbookwebsiteaddrdbms4036 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.5.0.pre.alpha.PBNTR606multilevelselectreset4035 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.5.0.pre.alpha.PLAY1548intltelinputupdatelatest4032 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.5.0.pre.alpha.PLAY1548intltelinputupdatelatest4028 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.6.0.pre.rc.12 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.6.0.pre.rc.11 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.6.0.pre.rc.10 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.6.0.pre.rc.9 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.6.0.pre.rc.8 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.6.0.pre.rc.7 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx
playbook_ui-14.6.0.pre.rc.6 app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx