Skip to content

The open alternative to Salesforce, designed for AI.

1.6 KB
Raw Blame
import { styled } from '@linaria/react';
import { type ReactNode } from 'react';
import { LightIconButton } from 'twenty-ui/components/input';
import { IconChevronLeft } from 'twenty-ui/icon';
import { themeCssVariables } from 'twenty-ui/theme';
import { useLingui } from '@lingui/react/macro';

type SettingsWizardStepBarProps = {
  label: ReactNode;
  onBack?: () => void;
  trailing?: ReactNode;
};

const StyledStepBar = styled.div`
  align-items: center;
  display: grid;
  flex: 1;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  min-width: 0;
`;

const StyledLeft = styled.div`
  align-items: center;
  display: flex;
  min-width: 0;
`;

const StyledLabel = styled.div`
  color: ${themeCssVariables.font.color.primary};
  font-size: ${themeCssVariables.font.size.md};
  font-weight: ${themeCssVariables.font.weight.semiBold};
  justify-self: center;
  min-width: 0;
  text-align: center;
`;

const StyledRight = styled.div`
  align-items: center;
  display: flex;
  gap: ${themeCssVariables.spacing[2]};
  justify-content: flex-end;
  min-width: 0;
`;

export const SettingsWizardStepBar = ({
  label,
  onBack,
  trailing,
}: SettingsWizardStepBarProps) => {
  const { t } = useLingui();
  return (
    <StyledStepBar>
      <StyledLeft>
        {onBack && (
          <LightIconButton
            size="sm"
            emphasis="subtle"
            onClick={onBack}
            aria-label={t`Previous`}
          >
            <IconChevronLeft />
          </LightIconButton>
        )}
      </StyledLeft>
      <StyledLabel>{label}</StyledLabel>
      <StyledRight>{trailing}</StyledRight>
    </StyledStepBar>
  );
};