@oaknational/oak-components 3.28.0 → 3.29.1

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.
@@ -0,0 +1,36 @@
1
+ import { __makeTemplateObject, __rest, __assign } from 'tslib';
2
+ import React from 'react';
3
+ import styled from 'styled-components';
4
+ import { lookupButtonBackground, lookupButtonPadding, lookupButtonBorderColor, lookupButtonBorderWidth, lookupButtonHoverBackground, lookupIconLoadingColor, lookupIconSize, lookupIconColor } from './variant.config.js';
5
+ import { focusStyles } from '../../../utils/focusStyles.js';
6
+ import { OakIcon } from '../../images-and-icons/OakIcon/OakIcon.js';
7
+ import '../../images-and-icons/OakImage/OakImage.js';
8
+ import '../../images-and-icons/OakSvg/OakSvg.js';
9
+ import '../../layout-and-structure/OakBox/OakBox.js';
10
+ import '../../images-and-icons/OakHandDrawnHR/OakHandDrawnHR.js';
11
+ import { OakLoadingSpinner } from '../../messaging-and-feedback/OakLoadingSpinner/OakLoadingSpinner.js';
12
+ import { parseBorderRadius } from '../../../styles/helpers/parseBorderRadius.js';
13
+ import { parseBorderWidth } from '../../../styles/helpers/parseBorderWidth.js';
14
+ import { parseColor } from '../../../styles/helpers/parseColor.js';
15
+ import { parseSpacing } from '../../../styles/helpers/parseSpacing.js';
16
+
17
+ var Button = styled.button(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n outline: none;\n border: none;\n display: flex;\n ", "\n cursor: ", ";\n background: ", ";\n padding: ", ";\n border-radius: ", ";\n border-style: solid;\n border-color: ", ";\n border-width: ", ";\n"], ["\n outline: none;\n border: none;\n display: flex;\n ", "\n cursor: ", ";\n background: ", ";\n padding: ", ";\n border-radius: ", ";\n border-style: solid;\n border-color: ", ";\n border-width: ", ";\n"])), focusStyles, function (props) { return (props.disabled ? "not-allowed" : "pointer"); }, function (props) { return parseColor(lookupButtonBackground(props)); }, function (props) { return parseSpacing(lookupButtonPadding(props)); }, parseBorderRadius("border-radius-circle"), function (props) { return parseColor(lookupButtonBorderColor(props)); }, function (props) { return parseBorderWidth(lookupButtonBorderWidth(props)); });
18
+ function defaultProps(props) {
19
+ return __assign({
20
+ // loading assumes the button is disabled
21
+ disabled: props.disabled || props.isLoading }, props);
22
+ }
23
+ /**
24
+ *
25
+ * Icon Buttons allow users to take actions, navigate, and make choices, with a single tap.
26
+ */
27
+ var OakIconButton = function (rawProps) {
28
+ var props = defaultProps(rawProps);
29
+ var iconName = props.iconName, isLoading = props.isLoading, rest = __rest(props, ["iconName", "isLoading"]);
30
+ return (React.createElement(Button, __assign({ "$hoverBackground": lookupButtonHoverBackground(props) }, rest),
31
+ isLoading && (React.createElement(OakLoadingSpinner, { "$width": lookupIconSize(props), loaderColor: lookupIconLoadingColor(props) })),
32
+ !isLoading && (React.createElement(OakIcon, { "$width": lookupIconSize(props), "$height": lookupIconSize(props), "$colorFilter": lookupIconColor(props), iconName: iconName }))));
33
+ };
34
+ var templateObject_1;
35
+
36
+ export { OakIconButton };
@@ -0,0 +1,104 @@
1
+ import { propsLookup } from '../../../utils/propsLookup.js';
2
+
3
+ var lookupButtonPadding = propsLookup([
4
+ [{ $size: "sm" }, "spacing-8"],
5
+ [{ $size: "md" }, "spacing-12"],
6
+ ]);
7
+ var lookupIconSize = propsLookup([
8
+ [{ $size: "sm" }, "spacing-20"],
9
+ [{ $size: "md" }, "spacing-24"],
10
+ ]);
11
+ var lookupButtonBackground = propsLookup([
12
+ [
13
+ { $type: "primary", $colorScheme: "primary", disabled: undefined },
14
+ "bg-btn-primary",
15
+ ],
16
+ [
17
+ { $type: "primary", $colorScheme: "inverted", disabled: undefined },
18
+ "bg-btn-secondary",
19
+ ],
20
+ [
21
+ { $type: "secondary", $colorScheme: "primary", disabled: undefined },
22
+ "bg-btn-secondary",
23
+ ],
24
+ [
25
+ { $type: "primary", $colorScheme: "primary", disabled: true },
26
+ "bg-btn-primary-disabled",
27
+ ],
28
+ [
29
+ { $type: "primary", $colorScheme: "inverted", disabled: true },
30
+ "bg-btn-secondary-disabled",
31
+ ],
32
+ [
33
+ { $type: "secondary", $colorScheme: "primary", disabled: true },
34
+ "bg-btn-secondary-disabled",
35
+ ],
36
+ ]);
37
+ var lookupIconLoadingColor = propsLookup([
38
+ [
39
+ { $type: "primary", $colorScheme: "primary", disabled: undefined },
40
+ "icon-inverted",
41
+ ],
42
+ [
43
+ { $type: "primary", $colorScheme: "inverted", disabled: undefined },
44
+ "icon-primary",
45
+ ],
46
+ [
47
+ { $type: "secondary", $colorScheme: "primary", disabled: undefined },
48
+ "icon-primary",
49
+ ],
50
+ [
51
+ { $type: "primary", $colorScheme: "primary", disabled: true },
52
+ "icon-inverted",
53
+ ],
54
+ [
55
+ { $type: "primary", $colorScheme: "inverted", disabled: true },
56
+ "icon-disabled",
57
+ ],
58
+ [
59
+ { $type: "secondary", $colorScheme: "primary", disabled: true },
60
+ "icon-disabled",
61
+ ],
62
+ ]);
63
+ var lookupIconColor = propsLookup([
64
+ [
65
+ { $type: "primary", $colorScheme: "primary", disabled: undefined },
66
+ "icon-inverted",
67
+ ],
68
+ [
69
+ { $type: "primary", $colorScheme: "inverted", disabled: undefined },
70
+ "icon-primary",
71
+ ],
72
+ [
73
+ { $type: "secondary", $colorScheme: "primary", disabled: undefined },
74
+ "icon-primary",
75
+ ],
76
+ [
77
+ { $type: "primary", $colorScheme: "primary", disabled: true },
78
+ "icon-inverted",
79
+ ],
80
+ [
81
+ { $type: "primary", $colorScheme: "inverted", disabled: true },
82
+ "icon-disabled",
83
+ ],
84
+ [
85
+ { $type: "secondary", $colorScheme: "primary", disabled: true },
86
+ "icon-disabled",
87
+ ],
88
+ ]);
89
+ var lookupButtonHoverBackground = propsLookup([
90
+ [{ $type: "primary", $colorScheme: "primary" }, "bg-btn-primary-hover"],
91
+ [{ $type: "primary", $colorScheme: "inverted" }, "bg-btn-secondary-hover"],
92
+ [{ $type: "secondary", $colorScheme: "primary" }, "bg-btn-secondary-hover"],
93
+ [{ $type: "secondary", $colorScheme: "inverted" }, "bg-btn-primary-hover"],
94
+ ]);
95
+ var lookupButtonBorderWidth = propsLookup([
96
+ [{ $type: "primary" }, "border-solid-none"],
97
+ [{ $type: "secondary" }, "border-solid-m"],
98
+ ]);
99
+ var lookupButtonBorderColor = propsLookup([
100
+ [{ $type: "secondary", disabled: undefined }, "border-primary"],
101
+ [{ $type: "secondary", disabled: true }, "border-neutral"],
102
+ ]);
103
+
104
+ export { lookupButtonBackground, lookupButtonBorderColor, lookupButtonBorderWidth, lookupButtonHoverBackground, lookupButtonPadding, lookupIconColor, lookupIconLoadingColor, lookupIconSize };
@@ -28,6 +28,7 @@ import '../../buttons/OakSecondaryButtonWithDropdown/OakSecondaryButtonWithDropd
28
28
  import '../../buttons/OakSmallSecondaryButtonWithDropdown/OakSmallSecondaryButtonWithDropdown.js';
29
29
  import '../../internal-components/InternalShadowIconButton/InternalShadowIconButton.js';
30
30
  import '../../buttons/OakLeftAlignedButton/OakLeftAlignedButton.js';
31
+ import '../../buttons/OakIconButton/OakIconButton.js';
31
32
 
32
33
  var OakErrorBoundaryBorderColor = createContext("border-neutral-lighter");
33
34
  /**
@@ -9,6 +9,7 @@ import { OakSmallSecondaryButton } from '../../buttons/OakSmallSecondaryButton/O
9
9
  import '../../buttons/OakSmallSecondaryButtonWithDropdown/OakSmallSecondaryButtonWithDropdown.js';
10
10
  import '../../internal-components/InternalShadowIconButton/InternalShadowIconButton.js';
11
11
  import '../../buttons/OakLeftAlignedButton/OakLeftAlignedButton.js';
12
+ import '../../buttons/OakIconButton/OakIconButton.js';
12
13
  import { OakFlex } from '../../layout-and-structure/OakFlex/OakFlex.js';
13
14
  import { OakBox } from '../../layout-and-structure/OakBox/OakBox.js';
14
15
  import '../../layout-and-structure/OakGrid/OakGrid.js';
@@ -198,6 +198,8 @@ var icons = {
198
198
  "video-2": "v1787662089/icons/video-2.svg",
199
199
  audio: "v1787662158/icons/audio.svg",
200
200
  "video-3": "v1788369484/icons/video-3.svg",
201
+ "sound-low": "v1794418270/icons/sound-low.svg",
202
+ "move-up-down": "v1794418662/icons/move-up-down.svg",
201
203
  };
202
204
  var backgrounds = {
203
205
  "confetti-pink": "v1734522868/pupil-journey/confetti-pink.svg",
@@ -1,3 +1,8 @@
1
+ export { OakIcon } from './components/images-and-icons/OakIcon/OakIcon.js';
2
+ export { OakImage, oakPlaceholder, placeholderStyles } from './components/images-and-icons/OakImage/OakImage.js';
3
+ export { OakSvg } from './components/images-and-icons/OakSvg/OakSvg.js';
4
+ export { OakRoundIcon } from './components/images-and-icons/OakRoundIcon/OakRoundIcon.js';
5
+ export { OakHandDrawnHR } from './components/images-and-icons/OakHandDrawnHR/OakHandDrawnHR.js';
1
6
  export { OakButtonWithDropdown } from './components/buttons/OakButtonWithDropdown/OakButtonWithDropdown.js';
2
7
  export { DropdownContext, OakButtonWithDropdownProvider } from './components/buttons/OakButtonWithDropdown/OakButtonWithDropdownProvider.js';
3
8
  export { useDropdownContext } from './components/buttons/OakButtonWithDropdown/useDropdownContext.js';
@@ -15,6 +20,7 @@ export { OakSmallTertiaryInvertedButton } from './components/buttons/OakSmallTer
15
20
  export { OakTertiaryButton } from './components/buttons/OakTertiaryButton/OakTertiaryButton.js';
16
21
  export { OakTertiaryInvertedButton } from './components/buttons/OakTertiaryInvertedButton/OakTertiaryInvertedButton.js';
17
22
  export { OakLeftAlignedButton } from './components/buttons/OakLeftAlignedButton/OakLeftAlignedButton.js';
23
+ export { OakIconButton } from './components/buttons/OakIconButton/OakIconButton.js';
18
24
  export { OakCookieBanner } from './components/cookies/OakCookieBanner/OakCookieBanner.js';
19
25
  export { OakCookieConsent } from './components/cookies/OakCookieConsent/OakCookieConsent.js';
20
26
  export { OakCookieConsentContext, OakCookieConsentProvider, getDefaultContextState, useCookieConsent } from './components/cookies/OakCookieConsentProvider/OakCookieConsentProvider.js';
@@ -38,11 +44,6 @@ export { OakOptGroup } from './components/form-elements/OakSelect/OakOptGroup.js
38
44
  export { OakTextInput } from './components/form-elements/OakTextInput/OakTextInput.js';
39
45
  export { OakRadioAsButton, colorSchemes } from './components/form-elements/OakRadioAsButton/OakRadioAsButton.js';
40
46
  export { OakSearchFilterCheckBox } from './components/form-elements/OakSearchFilterCheckBox/OakSearchFilterCheckBox.js';
41
- export { OakIcon } from './components/images-and-icons/OakIcon/OakIcon.js';
42
- export { OakImage, oakPlaceholder, placeholderStyles } from './components/images-and-icons/OakImage/OakImage.js';
43
- export { OakSvg } from './components/images-and-icons/OakSvg/OakSvg.js';
44
- export { OakRoundIcon } from './components/images-and-icons/OakRoundIcon/OakRoundIcon.js';
45
- export { OakHandDrawnHR } from './components/images-and-icons/OakHandDrawnHR/OakHandDrawnHR.js';
46
47
  export { OakFlex, oakFlexCss } from './components/layout-and-structure/OakFlex/OakFlex.js';
47
48
  export { OakBox, oakBoxCss } from './components/layout-and-structure/OakBox/OakBox.js';
48
49
  export { OakGrid } from './components/layout-and-structure/OakGrid/OakGrid.js';