Skip to content

Commit 77e0c20

Browse files
authored
feat: Add a network label (#443)
1 parent 52f3189 commit 77e0c20

File tree

12 files changed

+144
-14
lines changed

12 files changed

+144
-14
lines changed

packages/adena-extension/src/components/atoms/highlight-number/highlight-number.styles.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,32 @@
1+
import styled, { css, FlattenSimpleInterpolation } from 'styled-components';
12
import mixins from '@styles/mixins';
23
import { FontsType, fonts } from '@styles/theme';
3-
import styled, { FlattenSimpleInterpolation } from 'styled-components';
44

55
interface HighlightNumberWrapperProps {
66
fontColor: string;
77
fontStyleKey: FontsType;
88
minimumFontSize: string;
9+
lineHeight?: string;
910
}
1011

1112
export const HighlightNumberWrapper = styled.div<HighlightNumberWrapperProps>`
1213
${mixins.flex({ direction: 'row', align: 'normal', justify: 'normal' })};
1314
width: fit-content;
1415
height: auto;
15-
vertical-align: top;
1616
1717
.value {
1818
display: contents;
19-
${({ fontStyleKey }): FlattenSimpleInterpolation => fonts[fontStyleKey]};
2019
color: ${({ fontColor }): string => fontColor};
2120
text-align: bottom;
2221
22+
${({ fontStyleKey }): FlattenSimpleInterpolation => fonts[fontStyleKey]};
23+
${({ lineHeight }): FlattenSimpleInterpolation =>
24+
lineHeight
25+
? css`
26+
line-height: ${lineHeight};
27+
`
28+
: css``};
29+
2330
&.decimal {
2431
font-size: ${({ minimumFontSize }): string => minimumFontSize};
2532
}

packages/adena-extension/src/components/atoms/highlight-number/index.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@ export interface HighlightNumberProps {
77
fontColor?: string;
88
fontStyleKey?: FontsType;
99
minimumFontSize?: string;
10+
lineHeight?: string;
1011
}
1112

1213
export const HighlightNumber: React.FC<HighlightNumberProps> = ({
1314
value,
1415
fontColor = 'white',
1516
fontStyleKey = 'header6',
1617
minimumFontSize = '14px',
18+
lineHeight,
1719
}) => {
1820
const hasDecimal = value.includes('.');
1921
const [integer, decimal] = hasDecimal ? value.split('.') : [value, ''];
@@ -23,6 +25,7 @@ export const HighlightNumber: React.FC<HighlightNumberProps> = ({
2325
fontColor={fontColor}
2426
fontStyleKey={fontStyleKey}
2527
minimumFontSize={minimumFontSize}
28+
lineHeight={lineHeight}
2629
>
2730
<span className='value integer'>{integer}</span>
2831
<span className='value decimal'>

packages/adena-extension/src/components/molecules/token-balance/index.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export interface TokenBalanceProps {
1010
fontColor?: string;
1111
fontStyleKey?: FontsType;
1212
minimumFontSize?: string;
13+
lineHeight?: string;
1314
}
1415

1516
export const TokenBalance: React.FC<TokenBalanceProps> = ({
@@ -19,19 +20,22 @@ export const TokenBalance: React.FC<TokenBalanceProps> = ({
1920
fontColor = 'white',
2021
fontStyleKey = 'header6',
2122
minimumFontSize = '14px',
23+
lineHeight,
2224
}) => {
2325
return (
2426
<TokenBalanceWrapper
2527
orientation={orientation}
2628
fontColor={fontColor}
2729
fontStyleKey={fontStyleKey}
2830
minimumFontSize={minimumFontSize}
31+
lineHeight={lineHeight}
2932
>
3033
<HighlightNumber
3134
value={value}
3235
fontColor={fontColor}
3336
fontStyleKey={fontStyleKey}
3437
minimumFontSize={minimumFontSize}
38+
lineHeight={lineHeight}
3539
/>
3640
<div className='denom-wrapper'>
3741
<span className='denom'>{denom}</span>

packages/adena-extension/src/components/molecules/token-balance/token-balance.styles.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import { FontsType, fonts } from '@styles/theme';
2-
import styled, { FlattenSimpleInterpolation } from 'styled-components';
2+
import styled, { css, FlattenSimpleInterpolation } from 'styled-components';
33

44
interface TokenBalanceWrapperProps {
55
orientation: 'VERTICAL' | 'HORIZONTAL';
66
fontColor: string;
77
fontStyleKey: FontsType;
88
minimumFontSize: string;
9+
lineHeight?: string;
910
}
1011

1112
export const TokenBalanceWrapper = styled.div<TokenBalanceWrapperProps>`
@@ -24,7 +25,12 @@ export const TokenBalanceWrapper = styled.div<TokenBalanceWrapperProps>`
2425
display: contents;
2526
color: ${({ fontColor }): string => fontColor};
2627
${({ fontStyleKey }): FlattenSimpleInterpolation => fonts[fontStyleKey]};
27-
text-align: bottom;
28+
${({ lineHeight }): FlattenSimpleInterpolation =>
29+
lineHeight
30+
? css`
31+
line-height: ${lineHeight};
32+
`
33+
: css`sd`};
2834
}
2935
}
3036
`;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import React from 'react';
2+
import { RecoilRoot } from 'recoil';
3+
import { ThemeProvider } from 'styled-components';
4+
import { render } from '@testing-library/react';
5+
import theme from '@styles/theme';
6+
import MainNetworkLabel, { MainNetworkLabelProps } from './main-network-label';
7+
import { GlobalPopupStyle } from '@styles/global-style';
8+
9+
describe('MainNetworkLabel Component', () => {
10+
it('MainNetworkLabel render', () => {
11+
const args: MainNetworkLabelProps = {
12+
networkName: 'Network',
13+
};
14+
15+
render(
16+
<RecoilRoot>
17+
<GlobalPopupStyle />
18+
<ThemeProvider theme={theme}>
19+
<MainNetworkLabel {...args} />
20+
</ThemeProvider>
21+
</RecoilRoot>,
22+
);
23+
});
24+
});
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import MainNetworkLabel, { type MainNetworkLabelProps } from './main-network-label';
2+
import { Meta, StoryObj } from '@storybook/react';
3+
4+
export default {
5+
title: 'components/main/MainNetworkLabel',
6+
component: MainNetworkLabel,
7+
} as Meta<typeof MainNetworkLabel>;
8+
9+
export const Default: StoryObj<MainNetworkLabelProps> = {
10+
args: {
11+
networkName: 'Test3',
12+
},
13+
};
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import styled from 'styled-components';
2+
3+
import { View } from '@components/atoms';
4+
5+
export const MainNetworkLabelWrapper = styled(View)`
6+
width: 100%;
7+
height: auto;
8+
background-color: ${({ theme }): string => theme.primary._1};
9+
align-items: center;
10+
justify-content: center;
11+
height: 30px;
12+
`;
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import React from 'react';
2+
import { useTheme } from 'styled-components';
3+
import { Text } from '@components/atoms';
4+
import { MainNetworkLabelWrapper } from './main-network-label.styles';
5+
6+
export interface MainNetworkLabelProps {
7+
networkName: string;
8+
}
9+
10+
const MainNetworkLabel: React.FC<MainNetworkLabelProps> = ({ networkName }) => {
11+
const theme = useTheme();
12+
13+
return (
14+
<MainNetworkLabelWrapper>
15+
<Text
16+
style={{ display: 'flex', flexDirection: 'row' }}
17+
type='light13'
18+
color={theme.primary._2}
19+
>
20+
You are on <Text type='bold13'>{networkName}</Text>
21+
</Text>
22+
</MainNetworkLabelWrapper>
23+
);
24+
};
25+
26+
export default MainNetworkLabel;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { View } from '@components/atoms';
2+
import styled from 'styled-components';
3+
4+
export const MainTokenBalanceWrapper = styled(View)`
5+
width: 100%;
6+
height: auto;
7+
align-items: center;
8+
justify-content: center;
9+
`;

packages/adena-extension/src/components/pages/main/main-token-balance/main-token-balance.tsx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react';
22
import { TokenBalance } from '@components/molecules';
3+
import { MainTokenBalanceWrapper } from './main-token-balance.styles';
34

45
export interface MainTokenBalanceProps {
56
amount: {
@@ -12,14 +13,17 @@ const MainTokenBalance: React.FC<MainTokenBalanceProps> = ({ amount }) => {
1213
const { value, denom } = amount;
1314

1415
return (
15-
<TokenBalance
16-
value={value}
17-
denom={denom}
18-
orientation='VERTICAL'
19-
fontColor='white'
20-
fontStyleKey='header2'
21-
minimumFontSize='24px'
22-
/>
16+
<MainTokenBalanceWrapper>
17+
<TokenBalance
18+
value={value}
19+
denom={denom}
20+
orientation='VERTICAL'
21+
fontColor='white'
22+
fontStyleKey='header2'
23+
minimumFontSize='24px'
24+
lineHeight='39px'
25+
/>
26+
</MainTokenBalanceWrapper>
2327
);
2428
};
2529

0 commit comments

Comments
 (0)