-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCheckbox.js
More file actions
62 lines (61 loc) · 1.75 KB
/
Copy pathCheckbox.js
File metadata and controls
62 lines (61 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import React from 'react';
/**
* Checkbox — square check with ink fill.
*/
function Checkbox({
checked = false,
onChange,
disabled = false,
label,
style
}) {
return /*#__PURE__*/React.createElement("label", {
style: {
display: 'inline-flex',
alignItems: 'center',
gap: 10,
cursor: disabled ? 'not-allowed' : 'pointer',
opacity: disabled ? 0.5 : 1,
...style
}
}, /*#__PURE__*/React.createElement("button", {
type: "button",
role: "checkbox",
"aria-checked": checked,
disabled: disabled,
onClick: () => !disabled && onChange && onChange(!checked),
style: {
display: 'inline-flex',
alignItems: 'center',
justifyContent: 'center',
width: 20,
height: 20,
borderRadius: 'var(--radius-sm)',
border: '1px solid',
borderColor: checked ? 'var(--ink-900)' : 'var(--border-hairline)',
background: checked ? 'var(--ink-900)' : 'var(--surface-card)',
cursor: 'inherit',
padding: 0,
transition: 'background var(--dur) var(--ease), border-color var(--dur) var(--ease)'
}
}, checked && /*#__PURE__*/React.createElement("svg", {
width: "12",
height: "12",
viewBox: "0 0 12 12",
fill: "none"
}, /*#__PURE__*/React.createElement("path", {
d: "M2.5 6.2L5 8.5L9.5 3.5",
stroke: "var(--accent)",
strokeWidth: "1.8",
strokeLinecap: "round",
strokeLinejoin: "round"
}))), label && /*#__PURE__*/React.createElement("span", {
style: {
fontSize: 14,
letterSpacing: 'var(--tracking-tight)',
color: 'var(--text-body)'
}
}, label));
}
export default Checkbox;
})(); } catch (e) { __ds_ns.__errors.push({ path: "components/forms/Checkbox.jsx", error: String((e && e.message) || e) }); }