@hellobetterdigitalnz/selwynui 0.0.1-68 → 0.0.1-69

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hellobetterdigitalnz/selwynui",
3
- "version": "0.0.1-68",
3
+ "version": "0.0.1-69",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.es.js",
@@ -30,6 +30,7 @@
30
30
  "react-dom": "^19.2.0",
31
31
  "react-icons": "^5.5.0",
32
32
  "react-loading-skeleton": "^3.5.0",
33
+ "react-responsive-masonry": "^2.7.1",
33
34
  "react-slick": "^0.31.0",
34
35
  "sass": "^1.94.1",
35
36
  "slick-carousel": "^1.8.1",
@@ -54,6 +55,7 @@
54
55
  "@types/prop-types": "^15.7.15",
55
56
  "@types/react": "^19.2.2",
56
57
  "@types/react-dom": "^19.2.2",
58
+ "@types/react-responsive-masonry": "^2.7.0",
57
59
  "@types/react-slick": "^0.23.13",
58
60
  "@vitejs/plugin-react": "^5.1.0",
59
61
  "@vitest/browser-playwright": "^4.0.8",
@@ -1,5 +1,6 @@
1
1
  import styles from '../brandBuilder.module.scss'
2
2
  import BrandBuilderToolUploaderProps from "./BrandBuilderToolUploaderProps.tsx";
3
+ import Masonry from "react-responsive-masonry"
3
4
  const BrandBuilderToolUploader = (props : BrandBuilderToolUploaderProps) =>{
4
5
 
5
6
  const {action, children } = props
@@ -21,9 +22,11 @@ const BrandBuilderToolUploader = (props : BrandBuilderToolUploaderProps) =>{
21
22
  If you choose four, each image will be placed into its own segment of the selected shape, and the shape will automatically mask them.
22
23
  </p>
23
24
  </div>
24
- <>
25
- {children}
26
- </>
25
+ <div className={styles.imagesUploader}>
26
+ <Masonry gutter={'24px'} columnsCount={2}>
27
+ {children}
28
+ </Masonry>
29
+ </div>
27
30
  </div>
28
31
  }
29
32
 
@@ -129,6 +129,14 @@
129
129
 
130
130
  }
131
131
 
132
+ .imagesUploader{
133
+ position: relative;
134
+
135
+ img{
136
+ width: 100%;
137
+ }
138
+ }
139
+
132
140
  .brandBuilderToolUploader{
133
141
  border-bottom: 1px solid var(--color-block-text);
134
142
  margin-bottom: 24px;
@@ -0,0 +1,83 @@
1
+ import cx from "classnames";
2
+ import RadioButtonProps from "./RadioButtonProps";
3
+ import styles from "./radiobutton.module.scss";
4
+
5
+ const RadioButton = (props: RadioButtonProps) => {
6
+ const {
7
+ label,
8
+ name,
9
+ checked,
10
+ id,
11
+ value,
12
+ placeholder,
13
+ extraClass,
14
+ disabled,
15
+ error,
16
+ ariaLabel,
17
+ required,
18
+ readonly,
19
+ displaytype,
20
+ onChange,
21
+ ...args
22
+ } = props;
23
+
24
+ const classes = ["radio", styles.radio];
25
+ const classesHolders = [
26
+ "radioHolder",
27
+ styles.radioHolder,
28
+ `${displaytype === "box" && styles.radioBtnBox}`,
29
+ ];
30
+
31
+
32
+ if (extraClass) {
33
+ classes.push(extraClass);
34
+ }
35
+
36
+ if (disabled) {
37
+ classesHolders.push(styles.disabled);
38
+ }
39
+
40
+ if (error) {
41
+ classes.push(styles.error);
42
+ classesHolders.push(styles.error);
43
+ }
44
+
45
+ const handleChange = (e: any) => {
46
+ if (!readonly && !disabled) {
47
+ if (onChange) {
48
+ onChange(e, e.target.checked);
49
+ }
50
+ }
51
+ };
52
+
53
+ return (
54
+ <div className={styles.radioButtonWrap}>
55
+ <label className={cx(classesHolders)} onChange={handleChange}>
56
+ <div className={cx(classes)} >
57
+ <input
58
+ id={id}
59
+ name={name}
60
+ checked={checked}
61
+ type={"radio"}
62
+ value={value}
63
+ placeholder={placeholder}
64
+ disabled={disabled}
65
+ readOnly={readonly}
66
+ required={required}
67
+ aria-label={ariaLabel ? ariaLabel : name}
68
+ aria-required={required ? "true" : "false"}
69
+ aria-invalid={error ? "true" : "false"}
70
+ aria-disabled={disabled ? "true" : "false"}
71
+ aria-readonly={readonly ? "true" : "false"}
72
+ {...args}
73
+ />
74
+ <div className={styles.circle}></div>
75
+ </div>
76
+ {!!label && <label htmlFor={id}>{label}</label>}
77
+ </label>
78
+ </div>
79
+ );
80
+ };
81
+
82
+
83
+ export default RadioButton;
@@ -0,0 +1,24 @@
1
+ import { FocusEvent, MouseEvent } from "react";
2
+
3
+ interface RadioButtonProps {
4
+ label?:string | React.ReactNode;
5
+ name?: string;
6
+ id?: string;
7
+ value?: string;
8
+ extraClass?: string;
9
+ placeholder?: string;
10
+ error?: boolean;
11
+ disabled?: boolean;
12
+ readonly?: boolean;
13
+ checked?: boolean;
14
+ required?: boolean;
15
+ ariaLabel?: string;
16
+ ariaLabeledby?: string;
17
+ ariaDescribedby?: string;
18
+ onChange?: (e: MouseEvent, checked?: boolean) => void;
19
+ onFocus?: (e: FocusEvent) => void;
20
+ onBlur?: (e: FocusEvent) => void;
21
+ displaytype?: 'default' | 'box'
22
+ }
23
+
24
+ export default RadioButtonProps;
@@ -0,0 +1,129 @@
1
+ import type { Meta, StoryObj } from "@storybook/react-vite";
2
+ import RadioButtons from "./RadioButtons";
3
+ import RadioButton from "./RadioButton";
4
+ import React from 'react';
5
+
6
+ import "./radioButton.stories.scss";
7
+
8
+ const meta: Meta = {
9
+ title: "Form / Radio Button",
10
+ component: RadioButton,
11
+ parameters: {
12
+ layout: "centered"
13
+ },
14
+ tags: ["autodocs"]
15
+ };
16
+
17
+ export default meta;
18
+
19
+ type Story = StoryObj<typeof meta>;
20
+
21
+ const RadioButtoTemplate: Story = {
22
+ render: ({ items, ...args }) => {
23
+ return (
24
+ <div className={'visit'}>
25
+ <RadioButtons {...args}>
26
+ {items.map((item: any) => (
27
+ <RadioButton label={item.label} name={item.name} id={item.id} />
28
+ ))}
29
+ </RadioButtons>
30
+ </div>
31
+ );
32
+ }
33
+ };
34
+
35
+ const RadioButtonBoxTemplate: Story = {
36
+ render: ({ items, ...args }) => {
37
+ return (
38
+ <RadioButtons {...args}>
39
+ {items.map((item: any) => (
40
+ <RadioButton label={item.label} name={item.name} id={item.id} displaytype={item.displayType} />
41
+ ))}
42
+ </RadioButtons>
43
+ );
44
+ }
45
+ };
46
+
47
+ export const Default = {
48
+ ...RadioButtoTemplate,
49
+ args: {
50
+ columns: true,
51
+ items: [
52
+ {
53
+ id: "r-1",
54
+ name: "check-one",
55
+ disabled: true,
56
+ label: "Radio"
57
+ },
58
+ {
59
+ id: "r-2",
60
+ name: "check-one",
61
+ disabled: true,
62
+ label: "Radio"
63
+ },
64
+ {
65
+ id: "r-3",
66
+ name: "check-one",
67
+ disabled: true,
68
+ label: "Radio"
69
+ },
70
+ {
71
+ id: "r-4",
72
+ name: "check-one",
73
+ disabled: true,
74
+ label: "Radio"
75
+ },
76
+ {
77
+ id: "r-5",
78
+ name: "check-one",
79
+ disabled: true,
80
+ label: "Radio"
81
+ },
82
+ {
83
+ id: "r-6",
84
+ name: "check-one",
85
+ disabled: true,
86
+ label: "Radio"
87
+ }
88
+ ]
89
+ }
90
+ };
91
+
92
+ export const RadioButtonBox = {
93
+ ...RadioButtonBoxTemplate,
94
+ args: {
95
+ columns: false,
96
+
97
+ items: [
98
+ {
99
+ id: "r-1",
100
+ name: "check-one",
101
+ disabled: true,
102
+ label: "Radio",
103
+ displayType: "box"
104
+ },
105
+ {
106
+ id: "r-2",
107
+ name: "check-one",
108
+ disabled: true,
109
+ label: "Radio",
110
+ displayType: "box"
111
+ },
112
+ {
113
+ id: "r-3",
114
+ name: "check-one",
115
+ disabled: true,
116
+ label: "Radio",
117
+ displayType: "box"
118
+ },
119
+ {
120
+ id: "r-4",
121
+ name: "check-one",
122
+ disabled: true,
123
+ label: "Radio",
124
+ displayType: "box"
125
+ }
126
+ ]
127
+ }
128
+ };
129
+
@@ -0,0 +1,18 @@
1
+ import RadioButtonsProps from "./RadioButtonsProps";
2
+ import styles from "./radiobutton.module.scss";
3
+
4
+ const RadioButtons = (props: RadioButtonsProps) => {
5
+ const { children, columns, extraClass } = props;
6
+
7
+ return (
8
+ <div
9
+ className={`${styles.radioSet} ${extraClass} ${
10
+ columns ? styles.container : ""
11
+ }`}
12
+ >
13
+ {children}
14
+ </div>
15
+ );
16
+ };
17
+
18
+ export default RadioButtons;
@@ -0,0 +1,10 @@
1
+ import { ReactNode } from "react";
2
+
3
+ interface RadioButtonsProps {
4
+ children: ReactNode;
5
+ error?: boolean;
6
+ columns?: boolean;
7
+ extraClass?: string;
8
+ }
9
+
10
+ export default RadioButtonsProps;
@@ -0,0 +1,3 @@
1
+ .spacing {
2
+ padding: 4px;
3
+ }
@@ -0,0 +1,189 @@
1
+ .radioSet {
2
+ display: flex;
3
+ flex-wrap: wrap;
4
+ margin: calc(var(--space-unit) * -1);
5
+
6
+ &.container {
7
+ flex-direction: column;
8
+ }
9
+
10
+ &:has(.radioBtnBox) {
11
+ margin:0 -8px;
12
+ flex-wrap:nowrap;
13
+ }
14
+
15
+ }
16
+
17
+ .radioHolder {
18
+ display: inline-flex;
19
+ align-items: center;
20
+ padding: calc(var(--space-unit) * 1);
21
+
22
+ label {
23
+ cursor: pointer;
24
+ margin-left: calc(var(--space-unit) * 3);
25
+ }
26
+
27
+ &.error {
28
+ label {
29
+ color: var(--color-error);
30
+ }
31
+ }
32
+
33
+ &.disabled {
34
+ label {
35
+ cursor: not-allowed;
36
+ color: var(--color-text);
37
+ }
38
+ }
39
+
40
+ }
41
+
42
+ .radioButtonWrap {
43
+ display: flex;
44
+
45
+ &:has(.radioBtnBox) {
46
+ padding: 0 8px;
47
+ width: 100%;
48
+ }
49
+ }
50
+
51
+ .radioBtnBox {
52
+ border: 1px solid var(--color-text);
53
+ flex-direction: row-reverse;
54
+ padding:15px 24px;
55
+ justify-content: space-between;
56
+ border-radius: 4px;
57
+ width: 100%;
58
+ height: 100%;
59
+ cursor: pointer;
60
+
61
+ .container & {
62
+ margin-bottom: 16px;
63
+ }
64
+
65
+ label {
66
+ font-family: var(--font);
67
+ margin-left:0;
68
+ margin-right: 12px;
69
+ }
70
+
71
+
72
+ }
73
+
74
+
75
+ .radioBtnBox:has(input[type="radio"]:checked) {
76
+ --dropdown-border-color: var(--dropdown-selector-color);
77
+
78
+ }
79
+
80
+ [dir="rtl"] {
81
+ .radioHolder {
82
+ label {
83
+ margin-left: 0px;
84
+ margin-right: calc(var(--space-unit) * 3);
85
+ }
86
+ }
87
+ }
88
+ .radio {
89
+ position: relative;
90
+ display: inline-flex;
91
+ align-items: center;
92
+ justify-content: center;
93
+ flex-shrink: 0;
94
+ flex-grow: 0;
95
+
96
+ p {
97
+ font-size: var(--text-h-xxs);
98
+ line-height: var(--line-height-h-xxs);
99
+ font-family: var(--font);
100
+ }
101
+
102
+ input[type="radio"] {
103
+ -webkit-appearance: none;
104
+ width: 20px;
105
+ height: 20px;
106
+ border-radius: 100%;
107
+ background-color: #FFFFFF;
108
+ border: 1px solid var(--color-text);
109
+ outline-offset: 2px;
110
+ outline: 2px solid transparent;
111
+ cursor: pointer;
112
+ position: relative;
113
+ z-index: 1;
114
+
115
+ &:checked + .circle {
116
+ opacity: 1;
117
+ }
118
+
119
+
120
+
121
+ &:focus {
122
+ outline: 2px solid var(--color-text);
123
+ }
124
+
125
+ &:hover {
126
+ border: 2px solid var(--color-text);
127
+ }
128
+
129
+ &:disabled {
130
+ //background-color: var(--color-gr);
131
+ cursor: not-allowed;
132
+
133
+ &:checked {
134
+ border-color: var(--color-gray-200);
135
+ }
136
+ }
137
+ }
138
+
139
+ .circle {
140
+ content: "";
141
+ position: absolute;
142
+ width: 12px;
143
+ height: 12px;
144
+ border-radius: 100%;
145
+ background-color: var(--color-text);
146
+ opacity: 0;
147
+ pointer-events: none;
148
+ z-index: 10;
149
+ }
150
+ }
151
+
152
+
153
+ @media screen and (max-width: 768px) {
154
+ .radioBtnBox {
155
+ .container & {
156
+ margin-bottom: 0px;
157
+ }
158
+ }
159
+
160
+ .radioSet {
161
+ &:has(.radioBtnBox) {
162
+ flex-direction: column;
163
+ margin-left: 0;
164
+ margin-right: 0;
165
+ }
166
+ }
167
+
168
+ .radioButtonWrap {
169
+ &:has(.radioBtnBox) {
170
+ padding-left: 0;
171
+ padding-right: 0;
172
+
173
+ &:last-child {
174
+ .radioBtnBox {
175
+ border-bottom: 1px solid var(--color-text);
176
+ }
177
+ }
178
+ }
179
+ }
180
+
181
+ .radioBtnBox {
182
+ border-bottom: 1px solid transparent;
183
+ }
184
+
185
+ .radioBtnBox:has(input[type="radio"]:checked) {
186
+ border-bottom: 1px solid var(--color-text);
187
+
188
+ }
189
+ }