Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(tablekit-banner): fix icon alignment #40

Merged
merged 1 commit into from
Mar 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions packages/banner/src/Banner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Size } from '@tablecheck/tablekit-theme';

import {
adjustedIconSizes,
AlertIconWrapper,
AlertIcon,
BannerContainer,
BannerMessageContainer,
Expand Down Expand Up @@ -31,11 +32,13 @@ export const Banner = ({
>
<BannerMessageContainer>
{displayedIcon && (
<AlertIcon
className="bannerIcon"
icon={displayedIcon}
size={adjustedIconSizes[size]}
/>
<AlertIconWrapper size={size}>
<AlertIcon
className="bannerIcon"
icon={displayedIcon}
size={adjustedIconSizes[size]}
/>
</AlertIconWrapper>
)}
<div>{message}</div>
</BannerMessageContainer>
Expand Down
88 changes: 66 additions & 22 deletions packages/banner/src/__tests__/__snapshots__/index.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,18 @@ exports[`Banner should allow passing of custom className 1`] = `
}

.emotion-4 {
height: 24px;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-align-items: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
}

.emotion-6 {
margin-right: 8px;
}

Expand All @@ -64,20 +76,30 @@ exports[`Banner should allow passing of custom className 1`] = `
<div
className="emotion-2 emotion-3"
>
<AlertIcon
className="bannerIcon"
icon="fas-info-circle"
size="regular2"
<AlertIconWrapper
size="regular"
>
<Noop />
<Icon
className="bannerIcon emotion-4 emotion-5"
icon="fas-info-circle"
size="regular2"
<span
className="emotion-4 emotion-5"
size="regular"
>
icon-info-circle
</Icon>
</AlertIcon>
<AlertIcon
className="bannerIcon"
icon="fas-info-circle"
size="regular2"
>
<Noop />
<Icon
className="bannerIcon emotion-6 emotion-7"
icon="fas-info-circle"
size="regular2"
>
icon-info-circle
</Icon>
</AlertIcon>
</span>
</AlertIconWrapper>
<div>
Test
</div>
Expand Down Expand Up @@ -130,6 +152,18 @@ exports[`Banner should correctly apply styling 1`] = `
}

.emotion-4 {
height: 24px;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-align-items: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
}

.emotion-6 {
margin-right: 8px;
}

Expand All @@ -150,20 +184,30 @@ exports[`Banner should correctly apply styling 1`] = `
<div
className="emotion-2 emotion-3"
>
<AlertIcon
className="bannerIcon"
icon="fas-info-circle"
size="regular2"
<AlertIconWrapper
size="regular"
>
<Noop />
<Icon
className="bannerIcon emotion-4 emotion-5"
icon="fas-info-circle"
size="regular2"
<span
className="emotion-4 emotion-5"
size="regular"
>
icon-info-circle
</Icon>
</AlertIcon>
<AlertIcon
className="bannerIcon"
icon="fas-info-circle"
size="regular2"
>
<Noop />
<Icon
className="bannerIcon emotion-6 emotion-7"
icon="fas-info-circle"
size="regular2"
>
icon-info-circle
</Icon>
</AlertIcon>
</span>
</AlertIconWrapper>
<div>
Test
</div>
Expand Down
10 changes: 9 additions & 1 deletion packages/banner/src/styled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { getThemeValue } from '@tablecheck/tablekit-utils';
import type { ThemeOnlyProps } from '@tablecheck/tablekit-utils';

import { bannerClassicTheme, bannerThemeNamespace } from './themes';
import { Appearance, BannerProps } from './types';
import { Appearance, BannerProps, BannerSizes } from './types';

const sizedTypography = {
[Size.Small]: Typography.Heading4,
Expand Down Expand Up @@ -73,6 +73,14 @@ export const BannerMessageContainer = styled.div`
}
`;

export const AlertIconWrapper = styled.span<{
size: BannerSizes;
}>`
height: ${({ size }) => `${sizedTypography[size].lineHeight}`};
display: flex;
align-items: center;
`;

export const AlertIcon = styled(Icon)`
margin-right: ${Spacing.L2};
`;
Expand Down