@dtdot/lego 2.0.0-5 → 2.0.0-7

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.
@@ -33,9 +33,11 @@ const IconOuter = styled.span `
33
33
  justify-content: center;
34
34
 
35
35
  color: ${(props) => getThemeVariantColours(props.variant, props.theme).contrastText};
36
- background-color: ${(props) => getThemeVariantColours(props.variant, props.theme).darker};
36
+ background-color: ${(props) => props.iconOnly
37
+ ? getThemeVariantColours(props.variant, props.theme).main
38
+ : getThemeVariantColours(props.variant, props.theme).darker};
37
39
 
38
- height: ${(props) => getIconContainerSizePx(props.size).height};
40
+ height: ${(props) => props.height || getIconContainerSizePx(props.size).height};
39
41
  width: ${(props) => getIconContainerSizePx(props.size).width};
40
42
  `;
41
43
  const StyledButton = styled.button `
@@ -64,7 +66,9 @@ const StyledButton = styled.button `
64
66
  background-color: ${(props) => getThemeVariantColours(props.variant, props.theme).hover};
65
67
 
66
68
  ${IconOuter} {
67
- background-color: ${(props) => getThemeVariantColours(props.variant, props.theme).darkerHover};
69
+ background-color: ${(props) => props.iconOnly
70
+ ? getThemeVariantColours(props.variant, props.theme).hover
71
+ : getThemeVariantColours(props.variant, props.theme).darkerHover};
68
72
  }
69
73
  }
70
74
  `;
@@ -105,10 +109,10 @@ const ButtonSpinner = styled.div `
105
109
  const Button = React.forwardRef(function Button(props, ref) {
106
110
  const { children, loading, variant = 'primary', size = 'md', type = 'button', icon, onClick, 'data-cy': dataCy, } = props;
107
111
  const { width, height, alignSelf, marginTop } = useContext(ButtonContext);
108
- return (React.createElement(StyledButton, { ref: ref, width: width, height: height, alignSelf: alignSelf, marginTop: marginTop, variant: variant, size: size, type: type, onClick: onClick, "data-cy": dataCy || 'button' }, loading ? (React.createElement(SpinnerContainer, null,
109
- React.createElement(ButtonSpinner, { "data-cy": 'button-loading-spinner', variant: variant, size: size }))) : (React.createElement(ButtonInner, null,
112
+ return (React.createElement(StyledButton, { ref: ref, width: width, height: height, alignSelf: alignSelf, marginTop: marginTop, variant: variant, size: size, type: type, onClick: onClick, "data-cy": dataCy || 'button', iconOnly: !children }, loading ? (React.createElement(SpinnerContainer, null,
113
+ React.createElement(ButtonSpinner, { "data-cy": 'button-loading-spinner', variant: variant, size: size, iconOnly: !children }))) : (React.createElement(ButtonInner, null,
110
114
  children && React.createElement(ButtonTextContainer, { size: size }, children),
111
- icon && (React.createElement(IconOuter, { variant: variant, size: size },
115
+ icon && (React.createElement(IconOuter, { variant: variant, size: size, height: height, iconOnly: !children },
112
116
  React.createElement(FontAwesomeIcon, { icon: icon })))))));
113
117
  });
114
118
  export default Button;
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import { TableVariant } from './_Table.context';
3
+ import { TableActionProps } from './_TableAction';
3
4
  export type TableCellVariant = 'tight';
4
5
  export interface TableProps {
5
6
  children: React.ReactNode;
@@ -13,7 +14,8 @@ declare const Table: {
13
14
  Row: ({ children, "data-cy": dataCy }: import("./_TableRow.component").TableRowProps) => JSX.Element;
14
15
  Cell: import("styled-components").StyledComponent<"td", import("styled-components").DefaultTheme, TableCellProps, never>;
15
16
  ActionContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
16
- Action: ({ text, onClick, "data-cy": dataCy }: import("./_TableAction").TableActionProps) => JSX.Element;
17
+ Action: ({ text, variant, icon, onClick, "data-cy": dataCy }: TableActionProps) => JSX.Element;
17
18
  ActionMenu: ({ items, "data-cy": dataCy }: import("./_TableActionMenu").TableActionMenuProps) => JSX.Element;
19
+ HiddenAction: (props: TableActionProps) => JSX.Element;
18
20
  };
19
21
  export default Table;
@@ -9,6 +9,10 @@ import TableRow from './_TableRow.component';
9
9
  const StyledTable = styled.table `
10
10
  width: 100%;
11
11
  `;
12
+ const TableHiddenActionSpan = styled.span `
13
+ visibility: none;
14
+ opacity: 0;
15
+ `;
12
16
  const TableCell = styled.td `
13
17
  font-family: ${(props) => props.theme.fonts.default.family};
14
18
  font-size: ${(props) => props.theme.fonts.default.size};
@@ -18,7 +22,16 @@ const TableCell = styled.td `
18
22
 
19
23
  padding: ${(props) => (props.variant === 'tight' ? '0' : '0 16px')};
20
24
  height: 36px;
25
+
26
+ &:hover {
27
+ ${TableHiddenActionSpan} {
28
+ visibility: visible;
29
+ opacity: 1;
30
+ }
31
+ }
21
32
  `;
33
+ const TableHiddenAction = (props) => (React.createElement(TableHiddenActionSpan, null,
34
+ React.createElement(TableAction, { ...props })));
22
35
  const Table = ({ children, variant = 'regular' }) => {
23
36
  return (React.createElement(TableContext.Provider, { value: { variant } },
24
37
  React.createElement(ButtonContext.Provider, { value: { height: '24px' } },
@@ -30,4 +43,5 @@ Table.Cell = TableCell;
30
43
  Table.ActionContainer = TableActionContainer;
31
44
  Table.Action = TableAction;
32
45
  Table.ActionMenu = TableActionMenu;
46
+ Table.HiddenAction = TableHiddenAction;
33
47
  export default Table;
@@ -1,8 +1,12 @@
1
1
  /// <reference types="react" />
2
+ import { IconProp } from '@fortawesome/fontawesome-svg-core';
3
+ import { ColourVariant } from '../../theme/theme.types';
2
4
  export interface TableActionProps {
3
- 'text': string;
5
+ 'text'?: string;
6
+ 'variant'?: ColourVariant;
7
+ 'icon'?: IconProp;
4
8
  'onClick': () => void;
5
9
  'data-cy'?: string;
6
10
  }
7
- declare const TableAction: ({ text, onClick, "data-cy": dataCy }: TableActionProps) => JSX.Element;
11
+ declare const TableAction: ({ text, variant, icon, onClick, "data-cy": dataCy }: TableActionProps) => JSX.Element;
8
12
  export default TableAction;
@@ -1,6 +1,9 @@
1
- import React from 'react';
1
+ import React, { useContext } from 'react';
2
2
  import Button from '../Button/Button.component';
3
- const TableAction = ({ text, onClick, 'data-cy': dataCy }) => {
4
- return (React.createElement(Button, { variant: 'tertiary', onClick: onClick, "data-cy": dataCy || 'button-table-action' }, text));
3
+ import ButtonContext from '../Button/Button.context';
4
+ const TableAction = ({ text, variant, icon, onClick, 'data-cy': dataCy }) => {
5
+ const buttonContextVal = useContext(ButtonContext);
6
+ return (React.createElement(ButtonContext.Provider, { value: { ...buttonContextVal, ...(!text && icon && { width: '32px' }) } },
7
+ React.createElement(Button, { variant: variant || 'tertiary', icon: icon, onClick: onClick, "data-cy": dataCy || 'button-table-action' }, text)));
5
8
  };
6
9
  export default TableAction;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dtdot/lego",
3
- "version": "2.0.0-5",
3
+ "version": "2.0.0-7",
4
4
  "description": "Some reusable components for building my applications",
5
5
  "main": "build/index.js",
6
6
  "scripts": {