-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ring progress component. (#19793)
- Loading branch information
Showing
3 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
graylog2-web-interface/src/components/common/RingProgress.md
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,12 @@ | ||
```tsx | ||
<RingProgress sections={[{ value: 25, color: 'cyan' }]} label="25%" /> | ||
``` | ||
|
||
Example with multiple sections: | ||
```tsx | ||
<RingProgress sections={[ | ||
{ value: 40, color: 'cyan' }, | ||
{ value: 15, color: 'orange' }, | ||
{ value: 15, color: 'grape' }, | ||
]} /> | ||
``` |
33 changes: 33 additions & 0 deletions
33
graylog2-web-interface/src/components/common/RingProgress.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 @@ | ||
/* | ||
* Copyright (C) 2020 Graylog, Inc. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the Server Side Public License, version 1, | ||
* as published by MongoDB, Inc. | ||
* | ||
* 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 | ||
* Server Side Public License for more details. | ||
* | ||
* You should have received a copy of the Server Side Public License | ||
* along with this program. If not, see | ||
* <http://www.mongodb.com/licensing/server-side-public-license>. | ||
*/ | ||
import * as React from 'react'; | ||
import { RingProgress as MantineRingProgress } from '@mantine/core'; | ||
import styled from 'styled-components'; | ||
|
||
const LabelContainer = styled.div` | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
`; | ||
|
||
type Props = Pick<React.ComponentProps<typeof MantineRingProgress>, 'label' | 'size' | 'thickness' | 'sections'>; | ||
|
||
const RingProgress = ({ label, ...props }: Props) => ( | ||
<MantineRingProgress roundCaps label={<LabelContainer>{label}</LabelContainer>} {...props} /> | ||
); | ||
|
||
export default RingProgress; |
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