wca-designsystem 0.0.56 → 0.0.58
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/components/atomos/BarraDeProgresso/BarraDeProgresso.stories.tsx +18 -0
- package/src/components/atomos/BarraDeProgresso/BarraDeProgresso.test.tsx +12 -0
- package/src/components/atomos/BarraDeProgresso/index.tsx +29 -0
- package/src/components/atomos/BarraDeProgresso/styles.ts +27 -0
- package/src/components/organismos/Tabela/index.tsx +11 -9
package/package.json
CHANGED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import BarraDeProgresso from '.';
|
|
3
|
+
|
|
4
|
+
const meta: Meta<typeof BarraDeProgresso> = {
|
|
5
|
+
component: BarraDeProgresso,
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export default meta;
|
|
9
|
+
|
|
10
|
+
type Story = StoryObj<typeof BarraDeProgresso>;
|
|
11
|
+
|
|
12
|
+
export const Primary: Story = {
|
|
13
|
+
args: {
|
|
14
|
+
animated: true,
|
|
15
|
+
duracao: 200,
|
|
16
|
+
value: 50,
|
|
17
|
+
},
|
|
18
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import BarraDeProgresso from './index';
|
|
3
|
+
import { render } from '../../../test/render';
|
|
4
|
+
|
|
5
|
+
describe('Barra de Progresso', () => {
|
|
6
|
+
it('Renderiza corretamente', () => {
|
|
7
|
+
const { getByText } = render(<BarraDeProgresso value={10} duracao={200} />);
|
|
8
|
+
|
|
9
|
+
const BarraDeProgressoDefault = getByText('Sincronização em 70%');
|
|
10
|
+
expect(BarraDeProgressoDefault).toBeDefined();
|
|
11
|
+
});
|
|
12
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import * as S from './styles';
|
|
3
|
+
import { Progress, ProgressSectionProps } from '@mantine/core';
|
|
4
|
+
|
|
5
|
+
export interface BarraDeProgressoProps extends ProgressSectionProps {
|
|
6
|
+
duracao: number;
|
|
7
|
+
animated?: boolean;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const BarraDeProgresso = ({
|
|
11
|
+
duracao,
|
|
12
|
+
animated = false,
|
|
13
|
+
...props
|
|
14
|
+
}: BarraDeProgressoProps) => {
|
|
15
|
+
return (
|
|
16
|
+
<S.BarraDeProgressoContainer transitionDuration={duracao} size="xl">
|
|
17
|
+
<Progress.Section
|
|
18
|
+
// {...props}
|
|
19
|
+
{...props}
|
|
20
|
+
data-testid="progress-section"
|
|
21
|
+
animated={animated}
|
|
22
|
+
>
|
|
23
|
+
<Progress.Label>Sincronização em {props.value}% </Progress.Label>
|
|
24
|
+
</Progress.Section>
|
|
25
|
+
</S.BarraDeProgressoContainer>
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export default BarraDeProgresso;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Progress } from '@mantine/core';
|
|
2
|
+
import styled, { css } from 'styled-components';
|
|
3
|
+
|
|
4
|
+
export const BarraDeProgressoContainer = styled(Progress.Root)`
|
|
5
|
+
${({ theme }) => css`
|
|
6
|
+
border-radius: 4px;
|
|
7
|
+
height: 60px;
|
|
8
|
+
width: 100%;
|
|
9
|
+
padding: 0;
|
|
10
|
+
background-color: ${theme.colors.gray['500']};
|
|
11
|
+
|
|
12
|
+
.mantine-Progress-label {
|
|
13
|
+
font-size: ${theme.sizes.meddium};
|
|
14
|
+
font-weight: 600;
|
|
15
|
+
color: ${theme.colors.white};
|
|
16
|
+
text-align: center;
|
|
17
|
+
font-family: 'Open Sans', sans-serif;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.mantine-Progress-section {
|
|
21
|
+
background: ${theme.colors.blueNew};
|
|
22
|
+
box-shadow: 2px 0px 5px 0px rgba(0, 0, 0, 0.15);
|
|
23
|
+
border-radius: 4px;
|
|
24
|
+
height: 100%;
|
|
25
|
+
}
|
|
26
|
+
`}
|
|
27
|
+
`;
|
|
@@ -110,26 +110,28 @@ const Tabela = <T extends { id: string | number; children: Array<T> }>({
|
|
|
110
110
|
|
|
111
111
|
const topScrollRef = useRef<HTMLDivElement>(null);
|
|
112
112
|
const bottomScrollRef = useRef<HTMLDivElement>(null);
|
|
113
|
+
const tabelaRef = useRef<HTMLTableElement>(null);
|
|
113
114
|
|
|
114
115
|
// Sincroniza o scroll horizontal entre os dois scrollbars
|
|
115
116
|
useEffect(() => {
|
|
116
117
|
const topScroll = topScrollRef.current;
|
|
117
118
|
const bottomScroll = bottomScrollRef.current;
|
|
119
|
+
const tabela = bottomScrollRef.current;
|
|
118
120
|
|
|
119
121
|
if (topScroll && bottomScroll) {
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
+
const onTopScroll = () => {
|
|
123
|
+
bottomScroll.scrollLeft = topScroll.scrollLeft;
|
|
122
124
|
};
|
|
123
125
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
const onBottomScroll = () =>
|
|
128
|
-
topScroll && bottomScroll && syncScroll(bottomScroll, topScroll);
|
|
129
|
-
|
|
126
|
+
const onBottomScroll = () => {
|
|
127
|
+
topScroll.scrollLeft = bottomScroll.scrollLeft;
|
|
128
|
+
};
|
|
130
129
|
topScroll.addEventListener('scroll', onTopScroll);
|
|
131
130
|
bottomScroll.addEventListener('scroll', onBottomScroll);
|
|
132
131
|
|
|
132
|
+
// Atualiza o tamanho do scroll
|
|
133
|
+
if (tabela) setTamScroll(tabela.scrollWidth);
|
|
134
|
+
|
|
133
135
|
return () => {
|
|
134
136
|
topScroll.removeEventListener('scroll', onTopScroll);
|
|
135
137
|
bottomScroll.removeEventListener('scroll', onBottomScroll);
|
|
@@ -161,7 +163,7 @@ const Tabela = <T extends { id: string | number; children: Array<T> }>({
|
|
|
161
163
|
<S.FakeTable columnswidth={tamScroll} />
|
|
162
164
|
</S.ScrollWrapper>
|
|
163
165
|
<S.TableContainer ref={bottomScrollRef}>
|
|
164
|
-
<S.StyledTable>
|
|
166
|
+
<S.StyledTable ref={tabelaRef}>
|
|
165
167
|
{data?.length == 0 ? (
|
|
166
168
|
<></>
|
|
167
169
|
) : (
|