pipesol-button 1.0.1-beta.7 → 1.0.1-beta.9
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.
|
@@ -1,78 +1,37 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Props para o componente DownloadButton
|
|
4
4
|
*/
|
|
5
|
-
interface DownloadButtonProps {
|
|
6
|
-
/**
|
|
7
|
-
* **Arquivo a ser baixado**.
|
|
8
|
-
*
|
|
9
|
-
* - Pode ser um caminho relativo dentro do projeto (ex: `/arquivos/relatorio.pdf`),
|
|
10
|
-
* que o navegador tratará como download automático.
|
|
11
|
-
* - Pode ser uma URL absoluta/externa (ex: `https://exemplo.com/arquivo.zip`),
|
|
12
|
-
* que será aberta em nova aba para que o usuário faça o download.
|
|
13
|
-
*/
|
|
5
|
+
export interface DownloadButtonProps {
|
|
6
|
+
/** URL do arquivo a ser baixado */
|
|
14
7
|
file: string;
|
|
15
|
-
/**
|
|
16
|
-
|
|
17
|
-
/** Cor de fundo padrão
|
|
18
|
-
|
|
19
|
-
/** Cor de fundo
|
|
20
|
-
|
|
21
|
-
/** Cor do texto padrão
|
|
22
|
-
color
|
|
23
|
-
/** Cor do texto no hover
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
* @default "0"
|
|
33
|
-
*/
|
|
34
|
-
border_radius?: string;
|
|
35
|
-
/**
|
|
36
|
-
* Sombra CSS (ex: `0 2px 4px rgba(0,0,0,0.2)`).
|
|
37
|
-
* @default "none"
|
|
38
|
-
*/
|
|
39
|
-
box_shadow?: string;
|
|
40
|
-
/** Largura do botão (ex: `200px`, `100%`). */
|
|
41
|
-
width: string;
|
|
42
|
-
/**
|
|
43
|
-
* Margem externa.
|
|
44
|
-
* @default "0"
|
|
45
|
-
*/
|
|
46
|
-
margin?: string;
|
|
47
|
-
/**
|
|
48
|
-
* Padding interno.
|
|
49
|
-
* @default "8px 24px"
|
|
50
|
-
*/
|
|
51
|
-
padding?: string;
|
|
52
|
-
/** Conteúdo interno (texto ou elementos JSX). */
|
|
8
|
+
/** Nome do arquivo que será salvo */
|
|
9
|
+
fileName: string;
|
|
10
|
+
/** Cor de fundo padrão */
|
|
11
|
+
background?: string;
|
|
12
|
+
/** Cor de fundo no hover */
|
|
13
|
+
backgroundHover?: string;
|
|
14
|
+
/** Cor do texto padrão */
|
|
15
|
+
color?: string;
|
|
16
|
+
/** Cor do texto no hover */
|
|
17
|
+
colorHover?: string;
|
|
18
|
+
/** Raio da borda */
|
|
19
|
+
borderRadius?: string;
|
|
20
|
+
/** Sombra do botão */
|
|
21
|
+
boxShadow?: string;
|
|
22
|
+
/** Ícone opcional exibido à esquerda do texto */
|
|
23
|
+
icon?: React.ReactNode;
|
|
24
|
+
/** Texto do botão passado como children (deve ser um Typography) */
|
|
53
25
|
children: React.ReactNode;
|
|
54
26
|
}
|
|
55
27
|
/**
|
|
56
|
-
*
|
|
28
|
+
* Botão de download customizável com suporte a ícone e texto centralizado.
|
|
29
|
+
* O texto deve ser passado via `Typography` como children.
|
|
57
30
|
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
* Exemplo de uso:
|
|
64
|
-
* ```tsx
|
|
65
|
-
* <DownloadButton
|
|
66
|
-
* file="/docs/manual.pdf"
|
|
67
|
-
* aria_label="Baixar manual em PDF"
|
|
68
|
-
* background_color="#1976d2"
|
|
69
|
-
* color="#fff"
|
|
70
|
-
* border_radius="8px"
|
|
71
|
-
* width="200px"
|
|
72
|
-
* >
|
|
73
|
-
* Baixar Manual
|
|
74
|
-
* </DownloadButton>
|
|
75
|
-
* ```
|
|
31
|
+
* @default background="#1976d2"
|
|
32
|
+
* @default color="#fff"
|
|
33
|
+
* @default borderRadius="8px"
|
|
34
|
+
* @default boxShadow="none"
|
|
76
35
|
*/
|
|
77
36
|
declare const DownloadButton: React.FC<DownloadButtonProps>;
|
|
78
37
|
export default DownloadButton;
|
|
@@ -1,69 +1,44 @@
|
|
|
1
|
-
|
|
2
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
2
|
import { styled } from '@mui/material/styles';
|
|
4
|
-
const
|
|
3
|
+
const StyledLink = styled('a', {
|
|
5
4
|
shouldForwardProp: (prop) => ![
|
|
6
|
-
'
|
|
7
|
-
'
|
|
5
|
+
'background',
|
|
6
|
+
'backgroundHover',
|
|
8
7
|
'color',
|
|
9
|
-
'
|
|
10
|
-
'
|
|
11
|
-
'
|
|
12
|
-
'border_color',
|
|
13
|
-
'color_hover',
|
|
14
|
-
'width',
|
|
15
|
-
'margin',
|
|
16
|
-
'boxshadow',
|
|
8
|
+
'colorHover',
|
|
9
|
+
'borderRadius',
|
|
10
|
+
'boxShadow',
|
|
17
11
|
].includes(prop),
|
|
18
|
-
})(({
|
|
19
|
-
|
|
12
|
+
})(({ background, backgroundHover, color, colorHover, borderRadius, boxShadow }) => ({
|
|
13
|
+
display: 'inline-flex',
|
|
14
|
+
alignItems: 'center',
|
|
15
|
+
justifyContent: 'center',
|
|
16
|
+
gap: '8px',
|
|
17
|
+
background: background || '#1976d2',
|
|
18
|
+
color: color || '#fff',
|
|
19
|
+
borderRadius: borderRadius || '8px',
|
|
20
|
+
boxShadow: boxShadow || 'none',
|
|
21
|
+
padding: '8px 16px',
|
|
20
22
|
cursor: 'pointer',
|
|
21
23
|
textDecoration: 'none',
|
|
22
|
-
|
|
23
|
-
textAlign: 'center',
|
|
24
|
-
boxShadow: boxshadow,
|
|
25
|
-
backgroundColor: background_color,
|
|
26
|
-
color: color,
|
|
27
|
-
border: `1px solid ${border_color}`,
|
|
28
|
-
borderRadius: border_radius,
|
|
29
|
-
padding: padding,
|
|
30
|
-
margin: margin,
|
|
24
|
+
transition: 'all 0.3s ease',
|
|
31
25
|
'&:hover': {
|
|
32
|
-
|
|
33
|
-
color:
|
|
26
|
+
background: backgroundHover || '#1565c0',
|
|
27
|
+
color: colorHover || color || '#fff',
|
|
34
28
|
},
|
|
35
29
|
}));
|
|
36
30
|
/**
|
|
37
|
-
*
|
|
31
|
+
* Botão de download customizável com suporte a ícone e texto centralizado.
|
|
32
|
+
* O texto deve ser passado via `Typography` como children.
|
|
38
33
|
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
* Exemplo de uso:
|
|
45
|
-
* ```tsx
|
|
46
|
-
* <DownloadButton
|
|
47
|
-
* file="/docs/manual.pdf"
|
|
48
|
-
* aria_label="Baixar manual em PDF"
|
|
49
|
-
* background_color="#1976d2"
|
|
50
|
-
* color="#fff"
|
|
51
|
-
* border_radius="8px"
|
|
52
|
-
* width="200px"
|
|
53
|
-
* >
|
|
54
|
-
* Baixar Manual
|
|
55
|
-
* </DownloadButton>
|
|
56
|
-
* ```
|
|
34
|
+
* @default background="#1976d2"
|
|
35
|
+
* @default color="#fff"
|
|
36
|
+
* @default borderRadius="8px"
|
|
37
|
+
* @default boxShadow="none"
|
|
57
38
|
*/
|
|
58
|
-
const DownloadButton = ({ file,
|
|
59
|
-
|
|
60
|
-
const backgroundColorHover = background_color_hover !== null && background_color_hover !== void 0 ? background_color_hover : backgroundColor;
|
|
61
|
-
const colorHover = color_hover !== null && color_hover !== void 0 ? color_hover : color;
|
|
62
|
-
// Se sua rota de download for algo como /api/files/[file]/download,
|
|
63
|
-
// você pode ajustar aqui:
|
|
64
|
-
const downloadHref = `${file}/download`;
|
|
65
|
-
return (_jsx(ButtonStyled, { href: downloadHref, download // faz o navegador baixar ao invés de abrir, se suportado
|
|
66
|
-
: true, width: width, background_color: backgroundColor, background_color_hover: backgroundColorHover, color: color, color_hover: colorHover, border_radius: border_radius, border_color: border_color, padding: padding, margin: margin, "aria-label": aria_label, boxshadow: box_shadow, children: children }));
|
|
39
|
+
const DownloadButton = ({ file, fileName, background, backgroundHover, color, colorHover, borderRadius, boxShadow, icon, children, }) => {
|
|
40
|
+
return (_jsxs(StyledLink, { href: file, download: fileName, background: background, backgroundHover: backgroundHover, color: color, colorHover: colorHover, borderRadius: borderRadius, boxShadow: boxShadow, children: [icon && _jsx("span", { children: icon }), children] }));
|
|
67
41
|
};
|
|
42
|
+
DownloadButton.displayName = 'DownloadButton';
|
|
68
43
|
export default DownloadButton;
|
|
69
44
|
//# sourceMappingURL=DownloadButton.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DownloadButton.js","sourceRoot":"","sources":["../../src/components/DownloadButton.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DownloadButton.js","sourceRoot":"","sources":["../../src/components/DownloadButton.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AA4B9C,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,EAAE;IAC7B,iBAAiB,EAAE,CAAC,IAAI,EAAE,EAAE,CAC1B,CAAC;QACC,YAAY;QACZ,iBAAiB;QACjB,OAAO;QACP,YAAY;QACZ,cAAc;QACd,WAAW;KACZ,CAAC,QAAQ,CAAC,IAAc,CAAC;CAC7B,CAAC,CAOC,CAAC,EAAE,UAAU,EAAE,eAAe,EAAE,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,CAAC;IACnF,OAAO,EAAE,aAAa;IACtB,UAAU,EAAE,QAAQ;IACpB,cAAc,EAAE,QAAQ;IACxB,GAAG,EAAE,KAAK;IACV,UAAU,EAAE,UAAU,IAAI,SAAS;IACnC,KAAK,EAAE,KAAK,IAAI,MAAM;IACtB,YAAY,EAAE,YAAY,IAAI,KAAK;IACnC,SAAS,EAAE,SAAS,IAAI,MAAM;IAC9B,OAAO,EAAE,UAAU;IACnB,MA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