-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Auth device list component * Review * Fix licenses
- Loading branch information
Showing
16 changed files
with
648 additions
and
12 deletions.
There are no files selected for viewing
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
33 changes: 33 additions & 0 deletions
33
web/packages/design/src/MultiRowBox/MultiRowBox.story.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,33 @@ | ||
/** | ||
* Teleport | ||
* Copyright (C) 2024 Gravitational, Inc. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import React from 'react'; | ||
|
||
import { render } from 'design/utils/testing'; | ||
|
||
import { WithMultipleRows, WithSingleRow } from './MultiRowBox.story'; | ||
|
||
test('renders single row', () => { | ||
const { container } = render(<WithSingleRow />); | ||
expect(container.firstChild).toMatchSnapshot(); | ||
}); | ||
|
||
test('renders multiple rows', () => { | ||
const { container } = render(<WithMultipleRows />); | ||
expect(container.firstChild).toMatchSnapshot(); | ||
}); |
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,41 @@ | ||
/** | ||
* Teleport | ||
* Copyright (C) 2024 Gravitational, Inc. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import React from 'react'; | ||
|
||
import { MultiRowBox, Row, SingleRowBox } from './MultiRowBox'; | ||
|
||
export default { | ||
title: 'Design/MultiRowBox', | ||
component: MultiRowBox, | ||
}; | ||
|
||
export const WithMultipleRows = () => ( | ||
<MultiRowBox> | ||
<Row>Part 1</Row> | ||
<Row>Part 2</Row> | ||
<Row>Part 3</Row> | ||
</MultiRowBox> | ||
); | ||
|
||
export const WithSingleRow = () => ( | ||
<SingleRowBox> | ||
<div>Hello,</div> | ||
<div>World!</div> | ||
</SingleRowBox> | ||
); |
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,65 @@ | ||
/** | ||
* Teleport | ||
* Copyright (C) 2024 Gravitational, Inc. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import React, { ReactNode } from 'react'; | ||
|
||
import styled from 'styled-components'; | ||
|
||
import { Box } from 'design'; | ||
|
||
type MultiRowBoxProps = { | ||
children: ReactNode; | ||
}; | ||
|
||
/** | ||
* A box that displays a number of rows inside a rounded border, with horizontal | ||
* lines between rows. Use together with {@link Row}. Example: | ||
* | ||
* ```tsx | ||
* <MultiRowBox> | ||
* <Row>Row 1</Row> | ||
* <Row>Row 2</Row> | ||
* </MultiRowBox> | ||
* ``` | ||
*/ | ||
export const MultiRowBox = styled(Box)` | ||
border: ${props => | ||
`${props.theme.borders[1]} ${props.theme.colors.interactive.tonal.neutral[2]}`}; | ||
border-radius: ${props => props.theme.radii[2]}px; | ||
`; | ||
|
||
/** A single row of a {@link MultiRowBox}. */ | ||
export const Row = styled(Box)` | ||
padding: ${props => props.theme.space[4]}px; | ||
&:not(:last-child) { | ||
border-bottom: ${props => | ||
`${props.theme.borders[1]} ${props.theme.colors.interactive.tonal.neutral[2]}`}; | ||
} | ||
`; | ||
|
||
/** | ||
* A convenience utility to quickly render some components inside a single row | ||
* with a rounded border. | ||
*/ | ||
export function SingleRowBox({ children }: MultiRowBoxProps) { | ||
return ( | ||
<MultiRowBox> | ||
<Row>{children}</Row> | ||
</MultiRowBox> | ||
); | ||
} |
74 changes: 74 additions & 0 deletions
74
web/packages/design/src/MultiRowBox/__snapshots__/MultiRowBox.story.test.tsx.snap
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,74 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`renders multiple rows 1`] = ` | ||
.c0 { | ||
box-sizing: border-box; | ||
} | ||
.c1 { | ||
border: 1px solid rgba(255,255,255,0.18); | ||
border-radius: 4px; | ||
} | ||
.c2 { | ||
padding: 24px; | ||
} | ||
.c2:not(:last-child) { | ||
border-bottom: 1px solid rgba(255,255,255,0.18); | ||
} | ||
<div | ||
class="c0 c1" | ||
> | ||
<div | ||
class="c0 c2" | ||
> | ||
Part 1 | ||
</div> | ||
<div | ||
class="c0 c2" | ||
> | ||
Part 2 | ||
</div> | ||
<div | ||
class="c0 c2" | ||
> | ||
Part 3 | ||
</div> | ||
</div> | ||
`; | ||
|
||
exports[`renders single row 1`] = ` | ||
.c0 { | ||
box-sizing: border-box; | ||
} | ||
.c1 { | ||
border: 1px solid rgba(255,255,255,0.18); | ||
border-radius: 4px; | ||
} | ||
.c2 { | ||
padding: 24px; | ||
} | ||
.c2:not(:last-child) { | ||
border-bottom: 1px solid rgba(255,255,255,0.18); | ||
} | ||
<div | ||
class="c0 c1" | ||
> | ||
<div | ||
class="c0 c2" | ||
> | ||
<div> | ||
Hello, | ||
</div> | ||
<div> | ||
World! | ||
</div> | ||
</div> | ||
</div> | ||
`; |
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 @@ | ||
/** | ||
* Teleport | ||
* Copyright (C) 2024 Gravitational, Inc. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
export { MultiRowBox, SingleRowBox, Row } from './MultiRowBox'; |
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
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.