forstok-ui-lib 5.2.49 → 5.2.51

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": "forstok-ui-lib",
3
- "version": "5.2.49",
3
+ "version": "5.2.51",
4
4
  "description": "Forstok UI Components Library",
5
5
  "path": "dist",
6
6
  "main": "dist/index.js",
@@ -22,6 +22,7 @@ export { default as TextAreaComponent } from './textarea';
22
22
  export { default as TextAreaRefComponent } from './textarea/ref';
23
23
  export { default as DateComponent } from './date';
24
24
  export { default as DateTimeComponent } from './datetime';
25
+ export { default as RadioComponent } from './radio';
25
26
 
26
27
  export * from './dropdown/typed';
27
28
  export * from './message/typed';
@@ -0,0 +1,30 @@
1
+ import type { ChangeEvent, InputHTMLAttributes, ReactNode } from 'react';
2
+ import { RadioContainer, RadioInput, RadioSpan } from './styles';
3
+
4
+ type TRadio = InputHTMLAttributes<HTMLInputElement> & {
5
+ children?: ReactNode
6
+ $mode?: string
7
+ evChange?: (e: ChangeEvent<HTMLInputElement>) => void
8
+ 'data-qa-id'?: string
9
+ };
10
+
11
+ const RadioComponent = ({ children, $mode, evChange,...props }: TRadio) => {
12
+ const { id } = props;
13
+ return (
14
+ <RadioContainer>
15
+ <label htmlFor={id}>
16
+ <RadioInput
17
+ type='radio'
18
+ id={id}
19
+ $mode={$mode}
20
+ onChange={(e: ChangeEvent<HTMLInputElement>) => {
21
+ evChange && evChange(e)
22
+ }}
23
+ {...props} />
24
+ <RadioSpan $mode={$mode} {...props['data-qa-id'] && { 'data-qa-id': props['data-qa-id'] }}>{children}</RadioSpan>
25
+ </label>
26
+ </RadioContainer>
27
+ );
28
+ }
29
+
30
+ export default RadioComponent
@@ -0,0 +1,85 @@
1
+ import styled, { css } from 'styled-components'
2
+
3
+ import IconCheckmarkTick from '../../assets/images/icons/checkmark-tick.svg'
4
+
5
+ export const RadioContainer = styled.div`
6
+ display: grid;
7
+ grid-auto-flow: column;
8
+ justify-self: self-start;
9
+ `
10
+
11
+ export const RadioSpan = styled.span<{ $mode?: string }>`
12
+ position: relative;
13
+ cursor: pointer;
14
+ display: inline-block;
15
+ height: 16px;
16
+ transition: .28s ease;
17
+ user-select: none;
18
+ padding-left: 22px;
19
+ &:before,
20
+ &:after {
21
+ content: '';
22
+ position: absolute;
23
+ left: 0;
24
+ top: 0;
25
+ width: 10px;
26
+ height: 10px;
27
+ z-index: 0;
28
+ transition: .28s ease;
29
+ border: 2px solid #5a5a5a;
30
+ border-radius: 50%;
31
+ }
32
+ b {
33
+ line-height: 18px;
34
+ display: block;
35
+ }
36
+ .sub {
37
+ font-size: 90%;
38
+ color: #2d3c48;
39
+ }
40
+ ${({ $mode }:{ $mode?: string }) => {
41
+ if ($mode === 'check') {
42
+ return css`
43
+ &:before,
44
+ &:after {
45
+ border: none;
46
+ }
47
+ `
48
+ }
49
+ }}
50
+ `
51
+
52
+ export const RadioInput = styled.input<{ $mode?: string }>`
53
+ position: absolute;
54
+ opacity: 0;
55
+ pointer-events: none;
56
+ width: auto;
57
+ &:checked + ${RadioSpan} {
58
+ &:before {
59
+ border: 2px solid var(--err-clr-ln);
60
+ }
61
+ &:after {
62
+ transform: scale(0.6);
63
+ background-color: var(--err-clr-ln);
64
+ border: 2px solid transparent;
65
+ }
66
+ }
67
+ ${({ $mode }:{ $mode?: string }) => {
68
+ if ($mode === 'check') {
69
+ return css`
70
+ &:checked + ${RadioSpan} {
71
+ &:before,
72
+ &:after {
73
+ border: none;
74
+ transform: none;
75
+ background: none;
76
+ }
77
+ &:before {
78
+ content: url(${IconCheckmarkTick});
79
+ width: 14px;
80
+ }
81
+ }
82
+ `
83
+ }
84
+ }}
85
+ `