@coopdigital/react 1.8.1 → 1.9.0

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.
@@ -5,14 +5,14 @@ import { Image } from '../Image/Image.js';
5
5
  const Author = ({ author = "Co-op team", className, date, datePrefix = "", image = {
6
6
  alt: "",
7
7
  src: "https://s3.eu-west-1.amazonaws.com/assets.digital.coop.co.uk/oneweb/coop-logo-inverted.svg",
8
- }, ref, size = "md", ...props }) => {
8
+ }, ref, size, ...props }) => {
9
9
  const imageProps = {
10
10
  width: "56px",
11
11
  ...image,
12
12
  };
13
13
  const componentProps = {
14
14
  className: clsx("coop-author", className),
15
- "data-size": size.length && size !== "md" ? size : undefined,
15
+ "data-size": (size === null || size === void 0 ? void 0 : size.length) ? size : undefined,
16
16
  ...props,
17
17
  };
18
18
  return (jsxs("div", { ...componentProps, ref: ref, children: [image && jsx(Image, { ...imageProps }), jsxs("div", { className: "coop-author--content", children: [jsxs("span", { children: [jsx("span", { children: datePrefix ? datePrefix + " " : "" }), jsx("span", { className: "coop-author--date", children: date })] }), jsxs("span", { children: ["by ", author] })] })] }));
@@ -3,7 +3,7 @@ import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
3
3
  import clsx from 'clsx';
4
4
  import React, { useState, useCallback } from 'react';
5
5
  import { hasUserBg } from '../../utils/index.js';
6
- import { LoadingIcon } from '../icons/LoadingIcon.js';
6
+ import { LoadingSpinner } from '../LoadingSpinner/LoadingSpinner.js';
7
7
 
8
8
  const Button = ({ as, children, className, href, isDisabled = false, isFullWidth = false, isLoading = false, loadingText = "Loading", onClick, ref, size, variant = "solid", ...props }) => {
9
9
  const element = as !== null && as !== void 0 ? as : (href ? "a" : "button");
@@ -30,7 +30,7 @@ const Button = ({ as, children, className, href, isDisabled = false, isFullWidth
30
30
  onClick: onClick ? handleClick : undefined,
31
31
  ...props,
32
32
  };
33
- const finalChildren = isPending || isLoading ? (jsxs(Fragment, { children: [loadingText, jsx(LoadingIcon, { stroke: "currentColor", strokeWidth: "1px" })] })) : (children);
33
+ const finalChildren = isPending || isLoading ? (jsxs(Fragment, { children: [loadingText, jsx(LoadingSpinner, {})] })) : (children);
34
34
  return React.createElement(element, { ...componentProps, ref }, finalChildren);
35
35
  };
36
36
  Button.slot = { name: "Button" };
@@ -0,0 +1,13 @@
1
+ import type { JSX, Ref, SVGProps } from "react";
2
+ export interface LoadingSpinnerProps extends SVGProps<SVGSVGElement> {
3
+ /** **(Optional)** Specify additional CSS classes to be applied to the component. */
4
+ className?: string;
5
+ /** **(Optional)** Specify a custom React ref for this component. */
6
+ ref?: Ref<SVGSVGElement>;
7
+ /** **(Optional)** Specify LoadingSpinner stroke. */
8
+ stroke?: string;
9
+ /** **(Optional)** Specify LoadingSpinner stroke width. */
10
+ strokeWidth?: string;
11
+ }
12
+ export declare const LoadingSpinner: ({ className, ref, stroke, strokeWidth, ...props }: LoadingSpinnerProps) => JSX.Element;
13
+ export default LoadingSpinner;
@@ -0,0 +1,16 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import clsx from 'clsx';
3
+ import 'react';
4
+ import { LoadingIcon } from '../icons/LoadingIcon.js';
5
+
6
+ const LoadingSpinner = ({ className, ref, stroke = "currentColor", strokeWidth = "1px", ...props }) => {
7
+ const componentProps = {
8
+ className: clsx("coop-loading-spinner ", className),
9
+ stroke,
10
+ strokeWidth,
11
+ ...props,
12
+ };
13
+ return jsx(LoadingIcon, { ...componentProps, ref: ref });
14
+ };
15
+
16
+ export { LoadingSpinner, LoadingSpinner as default };
@@ -0,0 +1,4 @@
1
+ import LoadingSpinner from "./LoadingSpinner";
2
+ export default LoadingSpinner;
3
+ export { LoadingSpinner };
4
+ export * from "./LoadingSpinner";
package/dist/index.d.ts CHANGED
@@ -11,6 +11,7 @@ export * from "./components/Fieldset";
11
11
  export * from "./components/Flourish";
12
12
  export * from "./components/Form";
13
13
  export * from "./components/Image";
14
+ export * from "./components/LoadingSpinner";
14
15
  export * from "./components/Pill";
15
16
  export * from "./components/Popover";
16
17
  export * from "./components/Radio";
package/dist/index.js CHANGED
@@ -11,6 +11,7 @@ export { Fieldset, FieldsetError, FieldsetFields, FieldsetHint, FieldsetLegend }
11
11
  export { Flourish } from './components/Flourish/Flourish.js';
12
12
  export { Form } from './components/Form/Form.js';
13
13
  export { Image } from './components/Image/Image.js';
14
+ export { LoadingSpinner } from './components/LoadingSpinner/LoadingSpinner.js';
14
15
  export { Pill, PillBadge } from './components/Pill/Pill.js';
15
16
  export { Popover, PopoverAnchor, PopoverClose, PopoverContent, PopoverTrigger } from './components/Popover/Popover.js';
16
17
  export { Radio } from './components/Radio/Radio.js';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@coopdigital/react",
3
3
  "type": "module",
4
- "version": "1.8.1",
4
+ "version": "1.9.0",
5
5
  "private": false,
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -100,11 +100,11 @@
100
100
  "storybook": "$storybook"
101
101
  },
102
102
  "dependencies": {
103
- "@coopdigital/styles": "^1.5.1",
103
+ "@coopdigital/styles": "^1.6.0",
104
104
  "@radix-ui/react-popover": "^1.1.17",
105
105
  "clsx": "^2.1.1",
106
106
  "merge-refs": "^2.0.0",
107
107
  "react-day-picker": "^10.0.1"
108
108
  },
109
- "gitHead": "2bc73189fad734ed1efe037081705e97b63ab424"
109
+ "gitHead": "11857739418628c781dd2df457cc7365505e25f8"
110
110
  }
@@ -31,7 +31,7 @@ const Author = ({
31
31
  src: "https://s3.eu-west-1.amazonaws.com/assets.digital.coop.co.uk/oneweb/coop-logo-inverted.svg",
32
32
  },
33
33
  ref,
34
- size = "md",
34
+ size,
35
35
  ...props
36
36
  }: AuthorProps): JSX.Element => {
37
37
  const imageProps: ImageProps = {
@@ -41,7 +41,7 @@ const Author = ({
41
41
 
42
42
  const componentProps = {
43
43
  className: clsx("coop-author", className),
44
- "data-size": size.length && size !== "md" ? size : undefined,
44
+ "data-size": size?.length ? size : undefined,
45
45
  ...props,
46
46
  }
47
47
  return (
@@ -6,7 +6,7 @@ import clsx from "clsx"
6
6
  import React, { useCallback, useState } from "react"
7
7
 
8
8
  import { hasUserBg } from "../../utils"
9
- import { LoadingIcon } from "../icons"
9
+ import { LoadingSpinner } from "./../LoadingSpinner"
10
10
 
11
11
  export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
12
12
  /** **(Optional)** Specify a custom element to override default `a` or `button`. */
@@ -94,7 +94,7 @@ const Button = ({
94
94
  isPending || isLoading ? (
95
95
  <>
96
96
  {loadingText}
97
- <LoadingIcon stroke={"currentColor"} strokeWidth={"1px"} />
97
+ <LoadingSpinner />
98
98
  </>
99
99
  ) : (
100
100
  children
@@ -0,0 +1,35 @@
1
+ import type { JSX, Ref, SVGProps } from "react"
2
+
3
+ import clsx from "clsx"
4
+
5
+ import { LoadingIcon } from "../icons"
6
+
7
+ export interface LoadingSpinnerProps extends SVGProps<SVGSVGElement> {
8
+ /** **(Optional)** Specify additional CSS classes to be applied to the component. */
9
+ className?: string
10
+ /** **(Optional)** Specify a custom React ref for this component. */
11
+ ref?: Ref<SVGSVGElement>
12
+ /** **(Optional)** Specify LoadingSpinner stroke. */
13
+ stroke?: string
14
+ /** **(Optional)** Specify LoadingSpinner stroke width. */
15
+ strokeWidth?: string
16
+ }
17
+
18
+ export const LoadingSpinner = ({
19
+ className,
20
+ ref,
21
+ stroke = "currentColor",
22
+ strokeWidth = "1px",
23
+ ...props
24
+ }: LoadingSpinnerProps): JSX.Element => {
25
+ const componentProps = {
26
+ className: clsx("coop-loading-spinner ", className),
27
+ stroke,
28
+ strokeWidth,
29
+ ...props,
30
+ }
31
+
32
+ return <LoadingIcon {...componentProps} ref={ref} />
33
+ }
34
+
35
+ export default LoadingSpinner
@@ -0,0 +1,5 @@
1
+ import LoadingSpinner from "./LoadingSpinner"
2
+
3
+ export default LoadingSpinner
4
+ export { LoadingSpinner }
5
+ export * from "./LoadingSpinner"
package/src/index.ts CHANGED
@@ -11,6 +11,7 @@ export * from "./components/Fieldset"
11
11
  export * from "./components/Flourish"
12
12
  export * from "./components/Form"
13
13
  export * from "./components/Image"
14
+ export * from "./components/LoadingSpinner"
14
15
  export * from "./components/Pill"
15
16
  export * from "./components/Popover"
16
17
  export * from "./components/Radio"