forked from tari-project/tari
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Set up the Mining dashboard layout * Add handling mining node states * Add default mining box style and config * Fix typo and mining header styling
- Loading branch information
1 parent
8c2fa16
commit c9ac920
Showing
39 changed files
with
948 additions
and
57 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,4 +11,5 @@ export type BoxProps = { | |
border?: boolean | ||
style?: CSSProperties | ||
gradient?: Gradient | ||
testId?: string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
applications/launchpad_v2/src/components/CoinsList/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import Loading from '../Loading' | ||
import Text from '../Text' | ||
|
||
import { CoinsListItem, StyledCoinsList } from './styles' | ||
import { CoinsListProps } from './types' | ||
|
||
/** | ||
* Render the list of coins with amount. | ||
* @param {CoinProps[]} coins - the list of coins | ||
* @param {string} [color = 'inherit'] - the text color | ||
* | ||
* @typedef {CoinProps} | ||
* @param {string} amount - the amount | ||
* @param {string} unit - the unit, ie. xtr | ||
* @param {string} [suffixText] - the latter text after the amount and unit | ||
* @param {boolean} [loading] - is value being loaded | ||
*/ | ||
const CoinsList = ({ coins, color }: CoinsListProps) => { | ||
return ( | ||
<StyledCoinsList color={color}> | ||
{coins.map((c, idx) => ( | ||
<CoinsListItem key={`coin-${idx}`} loading={c.loading}> | ||
{c.loading ? ( | ||
<Loading loading={true} style={{ marginRight: 12 }} /> | ||
) : null} | ||
<Text type='subheader'>{c.amount}</Text> | ||
<Text | ||
as='span' | ||
type='smallMedium' | ||
style={{ | ||
paddingLeft: 4, | ||
paddingRight: 4, | ||
textTransform: 'uppercase', | ||
}} | ||
> | ||
{c.unit} | ||
</Text> | ||
{c.suffixText ? ( | ||
<Text as='span' type='smallMedium'> | ||
{c.suffixText} | ||
</Text> | ||
) : null} | ||
</CoinsListItem> | ||
))} | ||
</StyledCoinsList> | ||
) | ||
} | ||
|
||
export default CoinsList |
14 changes: 14 additions & 0 deletions
14
applications/launchpad_v2/src/components/CoinsList/styles.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import styled from 'styled-components' | ||
|
||
export const StyledCoinsList = styled.ul<{ color?: string }>` | ||
color: ${({ color }) => (color ? color : 'inherit')}; | ||
list-style: none; | ||
padding-left: 0; | ||
margin-top: 0; | ||
` | ||
|
||
export const CoinsListItem = styled.li<{ loading?: boolean }>` | ||
opacity: ${({ loading }) => (loading ? 0.64 : 1)}; | ||
display: flex; | ||
align-items: center; | ||
` |
11 changes: 11 additions & 0 deletions
11
applications/launchpad_v2/src/components/CoinsList/types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export interface CoinProps { | ||
amount: string | ||
unit: string | ||
suffixText?: string | ||
loading?: boolean | ||
} | ||
|
||
export interface CoinsListProps { | ||
coins: CoinProps[] | ||
color?: string | ||
} |
19 changes: 19 additions & 0 deletions
19
applications/launchpad_v2/src/components/NodeBox/NodeBox.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { render, screen } from '@testing-library/react' | ||
import { ThemeProvider } from 'styled-components' | ||
|
||
import themes from '../../styles/themes' | ||
|
||
import NodeBox from '.' | ||
|
||
describe('NodeBox', () => { | ||
it('should render without crashing', async () => { | ||
render( | ||
<ThemeProvider theme={themes.light}> | ||
<NodeBox /> | ||
</ThemeProvider>, | ||
) | ||
|
||
const el = screen.getByTestId('node-box-cmp') | ||
expect(el).toBeInTheDocument() | ||
}) | ||
}) |
66 changes: 66 additions & 0 deletions
66
applications/launchpad_v2/src/components/NodeBox/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import Box from '../Box' | ||
import Tag from '../Tag' | ||
import Text from '../Text' | ||
|
||
import { BoxHeader, BoxContent, NodeBoxPlacholder } from './styles' | ||
import { NodeBoxContentPlaceholderProps, NodeBoxProps } from './types' | ||
|
||
/** | ||
* The advanced Box component handling: | ||
* - custom title | ||
* - header tag | ||
* - background depending on the status prop | ||
* | ||
* Used for the UI representation of the Node (Docker container) as a Box component. | ||
* | ||
* @param {string} [title] - the box heading | ||
* @param {{ text: string; type?: TagType }} [tag = 'inactive'] - the status of the box/node | ||
* @param {CSSWithSpring} [style] - the box style | ||
* @param {CSSWithSpring} [titleStyle] - the title style | ||
* @param {CSSWithSpring} [contentStyle] - the content style | ||
* @param {ReactNode} [children] - the box heading | ||
*/ | ||
const NodeBox = ({ | ||
title, | ||
tag, | ||
style, | ||
titleStyle, | ||
contentStyle, | ||
children, | ||
}: NodeBoxProps) => { | ||
return ( | ||
<Box testId='node-box-cmp' style={style}> | ||
<BoxHeader> | ||
{tag ? ( | ||
<Tag type={tag.type} variant='large'> | ||
{tag.text} | ||
</Tag> | ||
) : null} | ||
</BoxHeader> | ||
{title ? ( | ||
<Text as='h2' type='header' style={titleStyle}> | ||
{title} | ||
</Text> | ||
) : null} | ||
<BoxContent style={contentStyle}>{children}</BoxContent> | ||
</Box> | ||
) | ||
} | ||
|
||
/** | ||
* Simple placholder container for the node box that provides default spacing and layout. | ||
* @param {string | ReactNode} children - the content | ||
*/ | ||
export const NodeBoxContentPlaceholder = ({ | ||
children, | ||
}: NodeBoxContentPlaceholderProps) => { | ||
let content = children | ||
|
||
if (typeof children === 'string') { | ||
content = <Text color='inherit'>{children}</Text> | ||
} | ||
|
||
return <NodeBoxPlacholder>{content}</NodeBoxPlacholder> | ||
} | ||
|
||
export default NodeBox |
20 changes: 20 additions & 0 deletions
20
applications/launchpad_v2/src/components/NodeBox/styles.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import styled from 'styled-components' | ||
|
||
export const BoxHeader = styled.div` | ||
height: 36px; | ||
` | ||
|
||
export const BoxContent = styled.div` | ||
padding-top: ${({ theme }) => theme.spacingVertical(1)}; | ||
padding-bottom: ${({ theme }) => theme.spacingVertical(1)}; | ||
min-height: 136px; | ||
display: flex; | ||
flex-direction: column; | ||
` | ||
|
||
export const NodeBoxPlacholder = styled.div` | ||
display: flex; | ||
flex: 1; | ||
padding-top: ${({ theme }) => theme.spacingVertical(1)}; | ||
padding-bottom: ${({ theme }) => theme.spacingVertical(1)}; | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { ReactNode } from 'react' | ||
import { CSSWithSpring } from '../../types/general' | ||
import { TagType } from '../Tag/types' | ||
|
||
export interface NodeBoxProps { | ||
title?: string | ||
tag?: { | ||
text: string | ||
type?: TagType | ||
} | ||
style?: CSSWithSpring | ||
titleStyle?: CSSWithSpring | ||
contentStyle?: CSSWithSpring | ||
children?: ReactNode | ||
} | ||
|
||
export interface NodeBoxContentPlaceholderProps { | ||
children: string | ReactNode | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.