All files / modules/30-delegates/components/SectionContainer SectionContainer.tsx

100% Statements 14/14
100% Branches 6/6
100% Functions 3/3
100% Lines 11/11

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76              11x 11x 11x 11x   11x   11x 11x                               11x 11x                                   11x                 21x                                
/*
 * Copyright 2021 Harness Inc. All rights reserved.
 * Use of this source code is governed by the PolyForm Shield 1.0.0 license
 * that can be found in the licenses directory at the root of this repository, also available at
 * https://polyformproject.org/wp-content/uploads/2020/06/PolyForm-Shield-1.0.0.txt.
 */
 
import React, { ReactNode } from 'react'
import cx from 'classnames'
import { Container, Text, TextProps, HarnessDocTooltip } from '@wings-software/uicore'
import { FontVariation } from '@harness/design-system'
import type { ContainerProps } from '@wings-software/uicore/dist/components/Container/Container'
import css from './SectionContainer.module.scss'
 
export const SectionContainer: React.FC<ContainerProps> = ({ children, style, ...props }) => {
  return (
    <Container
      padding="xlarge"
      style={{
        background: 'var(--white)',
        boxShadow: '0px 0px 1px rgba(40, 41, 61, 0.08), 0px 0.5px 2px rgba(96, 97, 112, 0.16)',
        borderRadius: '4px',
        ...style
      }}
      {...props}
    >
      {children}
    </Container>
  )
}
 
export const SectionContainerTitle: React.FC<TextProps> = ({ children, style, ...props }) => {
  return (
    <Text
      font={{ size: 'medium', weight: 'bold' }}
      style={{ color: '#22272D', paddingBottom: 'var(--spacing-medium)', ...style }}
      {...props}
    >
      {children}
    </Text>
  )
}
 
interface SectionLabelValuePairProps {
  label: string
  value?: ReactNode
  ignoreLastElementStyling?: boolean
  dataTooltipId?: string
}
 
export const SectionLabelValuePair: React.FC<SectionLabelValuePairProps & ContainerProps> = ({
  label,
  value,
  className,
  ignoreLastElementStyling,
  children,
  dataTooltipId,
  ...props
}) => {
  return (
    <Container className={cx(css.entry, className, ignoreLastElementStyling && css.ignoreLast)} {...props}>
      <Text
        font={{ variation: FontVariation.BODY }}
        style={{
          color: 'var(--grey-450)'
        }}
        data-tooltip-id={dataTooltipId}
      >
        {label}
        {dataTooltipId ? <HarnessDocTooltip useStandAlone={true} tooltipId={dataTooltipId} /> : null}
      </Text>
      {value ? <Text font={{ variation: FontVariation.BODY }}>{value}</Text> : children}
    </Container>
  )
}