Fix style (#8475)
## Before  ## After 
This commit is contained in:
@ -50,6 +50,7 @@ export * from './info/components/Info';
|
||||
export * from './status/components/Status';
|
||||
export * from './tag/components/Tag';
|
||||
export * from './text/components/SeparatorLineText';
|
||||
export * from './text/components/HorizontalSeparator';
|
||||
export * from './tooltip/AppTooltip';
|
||||
export * from './tooltip/OverflowingTextWithTooltip';
|
||||
export * from './typography/components/H1Title';
|
||||
|
||||
@ -0,0 +1,53 @@
|
||||
import { JSX } from 'react';
|
||||
import styled from '@emotion/styled';
|
||||
|
||||
type HorizontalSeparatorProps = {
|
||||
visible?: boolean;
|
||||
text?: string;
|
||||
noMargin?: boolean;
|
||||
};
|
||||
const StyledSeparator = styled.div<HorizontalSeparatorProps>`
|
||||
background-color: ${({ theme }) => theme.border.color.medium};
|
||||
height: ${({ visible }) => (visible ? '1px' : 0)};
|
||||
margin-bottom: ${({ theme, noMargin }) => (noMargin ? 0 : theme.spacing(3))};
|
||||
margin-top: ${({ theme, noMargin }) => (noMargin ? 0 : theme.spacing(3))};
|
||||
width: 100%;
|
||||
`;
|
||||
|
||||
const StyledSeparatorContainer = styled.div<{ noMargin: boolean }>`
|
||||
align-items: center;
|
||||
display: flex;
|
||||
margin-bottom: ${({ theme, noMargin }) => (noMargin ? 0 : theme.spacing(3))};
|
||||
margin-top: ${({ theme, noMargin }) => (noMargin ? 0 : theme.spacing(3))};
|
||||
width: 100%;
|
||||
`;
|
||||
|
||||
const StyledLine = styled.div<HorizontalSeparatorProps>`
|
||||
background-color: ${({ theme }) => theme.border.color.medium};
|
||||
height: ${({ visible }) => (visible ? '1px' : 0)};
|
||||
flex-grow: 1;
|
||||
`;
|
||||
|
||||
const StyledText = styled.span`
|
||||
color: ${({ theme }) => theme.font.color.light};
|
||||
margin: 0 ${({ theme }) => theme.spacing(2)};
|
||||
white-space: nowrap;
|
||||
`;
|
||||
|
||||
export const HorizontalSeparator = ({
|
||||
visible = true,
|
||||
text = '',
|
||||
noMargin = false,
|
||||
}: HorizontalSeparatorProps): JSX.Element => (
|
||||
<>
|
||||
{text ? (
|
||||
<StyledSeparatorContainer noMargin={noMargin}>
|
||||
<StyledLine visible={visible} />
|
||||
{text && <StyledText>{text}</StyledText>}
|
||||
<StyledLine visible={visible} />
|
||||
</StyledSeparatorContainer>
|
||||
) : (
|
||||
<StyledSeparator visible={visible} noMargin={noMargin} />
|
||||
)}
|
||||
</>
|
||||
);
|
||||
@ -0,0 +1,15 @@
|
||||
import { Meta, StoryObj } from '@storybook/react';
|
||||
import { ComponentDecorator } from '@ui/testing';
|
||||
|
||||
import { HorizontalSeparator } from '../HorizontalSeparator';
|
||||
|
||||
const meta: Meta<typeof HorizontalSeparator> = {
|
||||
title: 'UI/Display/Text/HorizontalSeparator',
|
||||
component: HorizontalSeparator,
|
||||
decorators: [ComponentDecorator],
|
||||
};
|
||||
|
||||
export default meta;
|
||||
type Story = StoryObj<typeof HorizontalSeparator>;
|
||||
|
||||
export const Default: Story = {};
|
||||
Reference in New Issue
Block a user