@dtdot/lego 1.8.0 → 1.8.2

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,13 +1,17 @@
1
1
  import React from 'react';
2
+ import { IconProp } from '@fortawesome/fontawesome-svg-core';
2
3
  import { Status } from '../../theme/theme.types';
3
4
  interface BadgeSpanProps {
4
5
  variant: BadgeVariant;
6
+ useHover: boolean;
5
7
  }
6
8
  export declare const BadgeSpan: import("styled-components").StyledComponent<"span", import("styled-components").DefaultTheme, BadgeSpanProps, never>;
7
9
  export type BadgeVariant = Status;
8
10
  export interface BadgeProps {
9
11
  children: React.ReactNode;
10
12
  variant: BadgeVariant;
13
+ actionIcon?: IconProp;
14
+ onAction?: () => void;
11
15
  }
12
- declare const Badge: ({ children, variant }: BadgeProps) => JSX.Element;
16
+ declare const Badge: ({ children, variant, actionIcon, onAction }: BadgeProps) => JSX.Element;
13
17
  export default Badge;
@@ -1,3 +1,4 @@
1
+ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
1
2
  import React from 'react';
2
3
  import styled from 'styled-components';
3
4
  import getThemeStatusColour from '../../theme/helpers/getThemeStatusColour';
@@ -11,10 +12,27 @@ export const BadgeSpan = styled.span `
11
12
  font-family: ${(props) => props.theme.fonts.default.family};
12
13
  font-size: ${(props) => props.theme.fonts.default.size};
13
14
  font-weight: ${(props) => props.theme.fonts.default.weight};
15
+ line-height: ${(props) => props.theme.fonts.default.size};
14
16
 
15
17
  text-transform: lowercase;
18
+
19
+ &:hover {
20
+ background-color: ${(props) => props.useHover && getThemeStatusColour(props.variant, props.theme).hover};
21
+ }
22
+ `;
23
+ const ActionSpan = styled.span `
24
+ vertical-align: middle;
25
+ padding: 3px 7px;
26
+ margin: -3px -7px -3px 0;
27
+ cursor: pointer;
28
+ user-select: none;
29
+
30
+ font-size: ${(props) => props.theme.fonts.default.size};
16
31
  `;
17
- const Badge = ({ children, variant }) => {
18
- return (React.createElement(BadgeSpan, { variant: variant, "data-cy": 'badge' }, children));
32
+ const Badge = ({ children, variant, actionIcon, onAction }) => {
33
+ return (React.createElement(BadgeSpan, { variant: variant, useHover: !!actionIcon, "data-cy": 'badge' },
34
+ children,
35
+ actionIcon && (React.createElement(ActionSpan, { onClick: onAction },
36
+ React.createElement(FontAwesomeIcon, { icon: actionIcon })))));
19
37
  };
20
38
  export default Badge;
@@ -24,6 +24,6 @@ const BadgeSelector = ({ options, value, onChange }) => {
24
24
  const handleClick = (_value) => {
25
25
  onChange([_value]);
26
26
  };
27
- return (React.createElement(BadgeSelectorOuter, { "data-cy": 'badge-selector' }, options.map((option) => (React.createElement(InteractiveBadge, { key: option.value, variant: option.variant, inactive: !value.includes(option.value), onClick: () => handleClick(option.value), "data-cy": value.includes(option.value) ? 'badge-selected' : 'badge' }, option.name)))));
27
+ return (React.createElement(BadgeSelectorOuter, { "data-cy": 'badge-selector' }, options.map((option) => (React.createElement(InteractiveBadge, { useHover: false, key: option.value, variant: option.variant, inactive: !value.includes(option.value), onClick: () => handleClick(option.value), "data-cy": value.includes(option.value) ? 'badge-selected' : 'badge' }, option.name)))));
28
28
  };
29
29
  export default BadgeSelector;
@@ -1,4 +1,6 @@
1
+ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
1
2
  import React, { useState } from 'react';
3
+ import { faChevronDown, faChevronUp } from '@fortawesome/free-solid-svg-icons';
2
4
  import { motion } from 'framer-motion';
3
5
  import styled, { useTheme } from 'styled-components';
4
6
  import ControlDescription from '../../shared/ControlDescription';
@@ -18,6 +20,15 @@ const TextContainer = styled.div `
18
20
  align-items: center;
19
21
  height: 100%;
20
22
  `;
23
+ const IconContainer = styled.div `
24
+ position: absolute;
25
+ right: 0;
26
+ top: 0;
27
+ height: 48px;
28
+ padding: 0 16px;
29
+ display: flex;
30
+ align-items: center;
31
+ `;
21
32
  const PlaceholderText = styled.div `
22
33
  color: ${(props) => getThemeControlColours(props.theme).placeholder};
23
34
  `;
@@ -29,10 +40,12 @@ const OptionsContainer = styled.div `
29
40
  position: absolute;
30
41
  background-color: ${(props) => props.theme.colours.controlBackground};
31
42
  z-index: 10000;
43
+
44
+ box-shadow: ${(props) => props.theme.shadows.small};
32
45
  `;
33
46
  const Option = styled(motion.div) `
34
47
  color: ${(props) => getThemeControlColours(props.theme).font};
35
- background-color: ${(props) => props.theme.colours.controlBackground};
48
+ background-color: ${(props) => props.theme.colours.controlBackgroundDisabled};
36
49
  height: 36px;
37
50
  display: flex;
38
51
  align-items: center;
@@ -62,7 +75,9 @@ const Select = (props) => {
62
75
  React.createElement(SelectControl, { "data-cy": dataCy, onClick: () => setIsOpen(!isOpen) },
63
76
  React.createElement(TextContainer, null,
64
77
  !value && placeholder && React.createElement(PlaceholderText, null, placeholder),
65
- value && React.createElement(ValueText, null, valueLabel))),
78
+ value && React.createElement(ValueText, null, valueLabel)),
79
+ React.createElement(IconContainer, null,
80
+ React.createElement(FontAwesomeIcon, { icon: isOpen ? faChevronUp : faChevronDown }))),
66
81
  isOpen && (React.createElement(OptionsContainer, null, options.map((option) => (React.createElement(Option, { whileHover: { backgroundColor: theme.colours.controlBorder }, transition: { type: 'spring', duration: 0.2 }, key: option.value, onClick: () => selectValue(option) }, option.label)))))),
67
82
  splitDescription && (React.createElement(ControlDescription, null, splitDescription.map((line, index) => (React.createElement(React.Fragment, null,
68
83
  index !== 0 && React.createElement("br", null),
@@ -38,21 +38,25 @@ const darkTheme = {
38
38
  main: '#83bfff',
39
39
  contrast: '#191919',
40
40
  dull: '#0070e8',
41
+ hover: '#8fc5ff',
41
42
  },
42
43
  statusSuccess: {
43
44
  main: '#8ddaa9',
44
45
  contrast: '#191919',
45
46
  dull: '#35a35d',
47
+ hover: '#98deb2',
46
48
  },
47
49
  statusWarn: {
48
50
  main: '#f1a374',
49
51
  contrast: '#191919',
50
52
  dull: '#c35514',
53
+ hover: '#f2ac82',
51
54
  },
52
55
  statusDanger: {
53
56
  main: '#e87a7a',
54
57
  contrast: '#191919',
55
58
  dull: '#b51f1f',
59
+ hover: '#ea8787',
56
60
  },
57
61
  },
58
62
  fonts: {
@@ -39,21 +39,25 @@ const defaultTheme = {
39
39
  main: colours.blue,
40
40
  contrast: colours.blue,
41
41
  dull: colours.blue,
42
+ hover: colours.blue,
42
43
  },
43
44
  statusSuccess: {
44
45
  main: colours.green,
45
46
  contrast: colours.green,
46
47
  dull: colours.green,
48
+ hover: colours.green,
47
49
  },
48
50
  statusWarn: {
49
51
  main: colours.yellow,
50
52
  contrast: colours.yellow,
51
53
  dull: colours.yellow,
54
+ hover: colours.yellow,
52
55
  },
53
56
  statusDanger: {
54
57
  main: colours.red,
55
58
  contrast: colours.red,
56
59
  dull: colours.red,
60
+ hover: colours.red,
57
61
  },
58
62
  },
59
63
  fonts: {
@@ -9,6 +9,7 @@ export interface IStatus {
9
9
  main: string;
10
10
  contrast: string;
11
11
  dull: string;
12
+ hover: string;
12
13
  }
13
14
  export interface IFont {
14
15
  family: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dtdot/lego",
3
- "version": "1.8.0",
3
+ "version": "1.8.2",
4
4
  "description": "Some reusable components for building my applications",
5
5
  "main": "build/index.js",
6
6
  "scripts": {
@@ -15,8 +15,15 @@
15
15
  "author": "Simon Pratt <19920260+simonpratt@users.noreply.github.com>",
16
16
  "license": "ISC",
17
17
  "files": [
18
- "build"
18
+ "build",
19
+ "README.md",
20
+ "LICENSE"
19
21
  ],
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "git+https://github.com/simonpratt/lego.git"
25
+ },
26
+ "homepage": "https://dtdot-lego.pages.dev/",
20
27
  "devDependencies": {
21
28
  "@babel/cli": "^7.20.7",
22
29
  "@babel/core": "^7.20.7",
@@ -56,7 +63,7 @@
56
63
  "peerDependencies": {
57
64
  "react": "16 - 18",
58
65
  "react-dom": "16 - 18",
59
- "styled-components": "5.x"
66
+ "styled-components": ">= 5"
60
67
  },
61
68
  "dependencies": {
62
69
  "@fortawesome/fontawesome-svg-core": "^6.2.1",