@react-cupertino-ui/quick-action 0.0.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.
package/LICENSE ADDED
@@ -0,0 +1,24 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Anderson Lima
4
+
5
+ This project is inspired by Apple's design principles but is not affiliated with, endorsed, or sponsored by Apple Inc.
6
+
7
+
8
+ Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ of this software and associated documentation files (the "Software"), to deal
10
+ in the Software without restriction, including without limitation the rights
11
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ copies of the Software, and to permit persons to whom the Software is
13
+ furnished to do so, subject to the following conditions:
14
+
15
+ The above copyright notice and this permission notice shall be included in all
16
+ copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
+ SOFTWARE.
package/dist/index.css ADDED
@@ -0,0 +1,165 @@
1
+ .react-cupertino-ui-quick-action {
2
+ --quick-action-radius: 26px;
3
+ --quick-action-surface: rgba(255, 255, 255, 0.82);
4
+ position: relative;
5
+ display: inline-flex;
6
+ align-items: center;
7
+ justify-content: flex-start;
8
+ gap: 1rem;
9
+ width: 100%;
10
+ border: none;
11
+ border-radius: var(--quick-action-radius);
12
+ padding: 1rem 1.1rem;
13
+ text-align: left;
14
+ cursor: pointer;
15
+ background: transparent;
16
+ color: inherit;
17
+ transition: transform 240ms cubic-bezier(0.2, 0.8, 0.4, 1), box-shadow 240ms ease, background 240ms ease;
18
+ -webkit-tap-highlight-color: transparent;
19
+ isolation: isolate;
20
+ }
21
+ .react-cupertino-ui-quick-action.glass {
22
+ background: rgba(255, 255, 255, 0.72);
23
+ backdrop-filter: blur(var(--glass-blur, 40px)) saturate(var(--glass-saturation, 180%));
24
+ -webkit-backdrop-filter: blur(var(--glass-blur, 40px)) saturate(var(--glass-saturation, 180%));
25
+ border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.18));
26
+ box-shadow: var(--glass-shadow, 0 8px 32px rgba(0, 0, 0, 0.12));
27
+ position: relative;
28
+ overflow: hidden;
29
+ }
30
+ .react-cupertino-ui-quick-action.glass::before {
31
+ content: "";
32
+ position: absolute;
33
+ inset: 0;
34
+ background: var(--glass-highlight, linear-gradient(135deg, rgba(255, 255, 255, 0.4) 0%, transparent 55%));
35
+ border-radius: inherit;
36
+ opacity: var(--glass-highlight-opacity, 0.95);
37
+ pointer-events: none;
38
+ mix-blend-mode: screen;
39
+ }
40
+ .react-cupertino-ui-quick-action.glass {
41
+ box-shadow: 0 20px 50px rgba(15, 15, 15, 0.15);
42
+ }
43
+ .react-cupertino-ui-quick-action.layout-horizontal {
44
+ flex-direction: row;
45
+ }
46
+ .react-cupertino-ui-quick-action.layout-vertical {
47
+ flex-direction: column;
48
+ align-items: flex-start;
49
+ gap: 0.75rem;
50
+ }
51
+ .react-cupertino-ui-quick-action.layout-vertical .react-cupertino-ui-quick-action__media {
52
+ width: auto;
53
+ height: auto;
54
+ }
55
+ .react-cupertino-ui-quick-action.layout-vertical .react-cupertino-ui-quick-action__cta {
56
+ align-self: flex-end;
57
+ }
58
+ .react-cupertino-ui-quick-action.align-center {
59
+ align-items: center;
60
+ }
61
+ .react-cupertino-ui-quick-action:hover:not(.is-disabled) {
62
+ transform: translateY(-2px);
63
+ box-shadow: 0 24px 60px rgba(15, 15, 15, 0.18);
64
+ }
65
+ .react-cupertino-ui-quick-action:active:not(.is-disabled) {
66
+ transform: scale(0.98);
67
+ }
68
+ .react-cupertino-ui-quick-action.is-disabled {
69
+ opacity: 0.5;
70
+ cursor: not-allowed;
71
+ }
72
+ .react-cupertino-ui-quick-action__media {
73
+ width: 52px;
74
+ height: 52px;
75
+ border-radius: 18px;
76
+ background: color-mix(in srgb, var(--color-blue, #0a84ff), transparent 35%);
77
+ display: inline-flex;
78
+ align-items: center;
79
+ justify-content: center;
80
+ position: relative;
81
+ overflow: hidden;
82
+ }
83
+ .react-cupertino-ui-quick-action__media .icon-slot {
84
+ display: inline-flex;
85
+ align-items: center;
86
+ justify-content: center;
87
+ width: 28px;
88
+ height: 28px;
89
+ }
90
+ .react-cupertino-ui-quick-action__media .badge {
91
+ position: absolute;
92
+ bottom: -2px;
93
+ right: -2px;
94
+ min-width: 18px;
95
+ height: 18px;
96
+ padding: 0 0.35rem;
97
+ border-radius: 11px;
98
+ font-size: 0.68rem;
99
+ font-weight: 700;
100
+ background: rgba(255, 255, 255, 0.95);
101
+ color: #0a84ff;
102
+ box-shadow: 0 4px 12px rgba(15, 15, 15, 0.2);
103
+ }
104
+ .react-cupertino-ui-quick-action__body {
105
+ flex: 1;
106
+ min-width: 0;
107
+ }
108
+ .react-cupertino-ui-quick-action__header {
109
+ display: flex;
110
+ align-items: flex-start;
111
+ justify-content: space-between;
112
+ gap: 0.75rem;
113
+ }
114
+ .react-cupertino-ui-quick-action__header .title {
115
+ font-size: 1rem;
116
+ font-weight: 600;
117
+ color: hsl(var(--foreground, 240 10% 3.9%));
118
+ }
119
+ .react-cupertino-ui-quick-action__header .subtitle {
120
+ display: block;
121
+ font-size: 0.85rem;
122
+ color: color-mix(in srgb, currentColor, transparent 35%);
123
+ margin-top: 0.1rem;
124
+ }
125
+ .react-cupertino-ui-quick-action__header .metric {
126
+ font-size: 0.85rem;
127
+ font-weight: 600;
128
+ padding: 0.15rem 0.55rem;
129
+ border-radius: 999px;
130
+ background: rgba(0, 0, 0, 0.06);
131
+ color: inherit;
132
+ }
133
+ .react-cupertino-ui-quick-action__cta {
134
+ width: 36px;
135
+ height: 36px;
136
+ border-radius: 999px;
137
+ display: inline-flex;
138
+ align-items: center;
139
+ justify-content: center;
140
+ background: rgba(255, 255, 255, 0.65);
141
+ box-shadow: 0 10px 20px rgba(15, 15, 15, 0.12);
142
+ }
143
+ .react-cupertino-ui-quick-action .helper {
144
+ margin: 0.25rem 0 0;
145
+ font-size: 0.85rem;
146
+ color: color-mix(in srgb, currentColor, transparent 40%);
147
+ }
148
+ .react-cupertino-ui-quick-action.tone-success .react-cupertino-ui-quick-action__media {
149
+ background: color-mix(in srgb, var(--color-green, #34c759), transparent 30%);
150
+ }
151
+ .react-cupertino-ui-quick-action.tone-warning .react-cupertino-ui-quick-action__media {
152
+ background: color-mix(in srgb, #ff9f0a, transparent 35%);
153
+ }
154
+ .react-cupertino-ui-quick-action.tone-danger .react-cupertino-ui-quick-action__media {
155
+ background: color-mix(in srgb, var(--color-red, #ff3b30), transparent 30%);
156
+ }
157
+ .react-cupertino-ui-quick-action.tone-indigo .react-cupertino-ui-quick-action__media {
158
+ background: color-mix(in srgb, #7c3aed, transparent 25%);
159
+ }
160
+
161
+ @media (prefers-reduced-motion: reduce) {
162
+ .react-cupertino-ui-quick-action {
163
+ transition: none;
164
+ }
165
+ }
@@ -0,0 +1,22 @@
1
+ import * as React from "react";
2
+ import type { BaseProps } from "@react-cupertino-ui/shared/lib/interfaces/BaseProps";
3
+ import "./index.scss";
4
+ export type QuickActionTone = "default" | "success" | "warning" | "danger" | "indigo";
5
+ export type QuickActionLayout = "vertical" | "horizontal";
6
+ export interface QuickActionProps extends Omit<BaseProps<HTMLButtonElement>, "children" | "asChild"> {
7
+ title: string;
8
+ subtitle?: string;
9
+ icon?: React.ReactNode;
10
+ metric?: string;
11
+ badge?: string;
12
+ tone?: QuickActionTone;
13
+ layout?: QuickActionLayout;
14
+ glass?: boolean;
15
+ disabled?: boolean;
16
+ align?: "start" | "center";
17
+ helperText?: string;
18
+ onSelect?: () => void;
19
+ rightSlot?: React.ReactNode;
20
+ }
21
+ declare const QuickAction: React.ForwardRefExoticComponent<QuickActionProps & React.RefAttributes<HTMLButtonElement>>;
22
+ export { QuickAction };
package/dist/index.js ADDED
@@ -0,0 +1,18 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import * as React from "react";
3
+ import { ArrowRight } from "lucide-react";
4
+ import { cn } from "@react-cupertino-ui/shared/lib/utils";
5
+ import "./index.scss";
6
+ const QuickAction = React.forwardRef((props, ref) => {
7
+ const { title, subtitle, icon, metric, badge, tone = "default", layout = "vertical", glass = true, disabled = false, align = "start", helperText, onSelect, rightSlot, className, ...rest } = props;
8
+ const handleClick = (event) => {
9
+ if (disabled) {
10
+ event.preventDefault();
11
+ return;
12
+ }
13
+ onSelect?.();
14
+ };
15
+ return (_jsxs("button", { ref: ref, type: "button", className: cn("react-cupertino-ui-quick-action", glass && "glass", `tone-${tone}`, `layout-${layout}`, `align-${align}`, disabled && "is-disabled", className), "data-disabled": disabled ? "true" : undefined, onClick: handleClick, disabled: disabled, ...rest, children: [_jsxs("div", { className: "react-cupertino-ui-quick-action__media", "aria-hidden": "true", children: [icon ? _jsx("span", { className: "icon-slot", children: icon }) : null, badge ? _jsx("span", { className: "badge", children: badge }) : null] }), _jsxs("div", { className: "react-cupertino-ui-quick-action__body", children: [_jsxs("div", { className: "react-cupertino-ui-quick-action__header", children: [_jsxs("div", { children: [_jsx("span", { className: "title", children: title }), subtitle ? _jsx("span", { className: "subtitle", children: subtitle }) : null] }), metric ? _jsx("span", { className: "metric", children: metric }) : null] }), helperText ? _jsx("p", { className: "helper", children: helperText }) : null] }), _jsx("div", { className: "react-cupertino-ui-quick-action__cta", "aria-hidden": "true", children: rightSlot ?? _jsx(ArrowRight, { size: 16 }) })] }));
16
+ });
17
+ QuickAction.displayName = "QuickAction";
18
+ export { QuickAction };
@@ -0,0 +1,183 @@
1
+ @use "@/styles/mixins/glass" as glass;
2
+
3
+ .react-cupertino-ui-quick-action {
4
+ --quick-action-radius: 26px;
5
+ --quick-action-surface: rgba(255, 255, 255, 0.82);
6
+ position: relative;
7
+ display: inline-flex;
8
+ align-items: center;
9
+ justify-content: flex-start;
10
+ gap: 1rem;
11
+ width: 100%;
12
+ border: none;
13
+ border-radius: var(--quick-action-radius);
14
+ padding: 1rem 1.1rem;
15
+ text-align: left;
16
+ cursor: pointer;
17
+ background: transparent;
18
+ color: inherit;
19
+ transition:
20
+ transform 240ms cubic-bezier(0.2, 0.8, 0.4, 1),
21
+ box-shadow 240ms ease,
22
+ background 240ms ease;
23
+ -webkit-tap-highlight-color: transparent;
24
+ isolation: isolate;
25
+
26
+ &.glass {
27
+ @include glass.glass-panel(light, var(--glass-blur, 40px), 0.72);
28
+ box-shadow: 0 20px 50px rgba(15, 15, 15, 0.15);
29
+ }
30
+
31
+ &.layout-horizontal {
32
+ flex-direction: row;
33
+ }
34
+
35
+ &.layout-vertical {
36
+ flex-direction: column;
37
+ align-items: flex-start;
38
+ gap: 0.75rem;
39
+
40
+ .react-cupertino-ui-quick-action__media {
41
+ width: auto;
42
+ height: auto;
43
+ }
44
+
45
+ .react-cupertino-ui-quick-action__cta {
46
+ align-self: flex-end;
47
+ }
48
+ }
49
+
50
+ &.align-center {
51
+ align-items: center;
52
+ }
53
+
54
+ &:hover:not(.is-disabled) {
55
+ transform: translateY(-2px);
56
+ box-shadow: 0 24px 60px rgba(15, 15, 15, 0.18);
57
+ }
58
+
59
+ &:active:not(.is-disabled) {
60
+ transform: scale(0.98);
61
+ }
62
+
63
+ &.is-disabled {
64
+ opacity: 0.5;
65
+ cursor: not-allowed;
66
+ }
67
+
68
+ &__media {
69
+ width: 52px;
70
+ height: 52px;
71
+ border-radius: 18px;
72
+ background: color-mix(in srgb, var(--color-blue, #0a84ff), transparent 35%);
73
+ display: inline-flex;
74
+ align-items: center;
75
+ justify-content: center;
76
+ position: relative;
77
+ overflow: hidden;
78
+
79
+ .icon-slot {
80
+ display: inline-flex;
81
+ align-items: center;
82
+ justify-content: center;
83
+ width: 28px;
84
+ height: 28px;
85
+ }
86
+
87
+ .badge {
88
+ position: absolute;
89
+ bottom: -2px;
90
+ right: -2px;
91
+ min-width: 18px;
92
+ height: 18px;
93
+ padding: 0 0.35rem;
94
+ border-radius: 11px;
95
+ font-size: 0.68rem;
96
+ font-weight: 700;
97
+ background: rgba(255, 255, 255, 0.95);
98
+ color: #0a84ff;
99
+ box-shadow: 0 4px 12px rgba(15, 15, 15, 0.2);
100
+ }
101
+ }
102
+
103
+ &__body {
104
+ flex: 1;
105
+ min-width: 0;
106
+ }
107
+
108
+ &__header {
109
+ display: flex;
110
+ align-items: flex-start;
111
+ justify-content: space-between;
112
+ gap: 0.75rem;
113
+
114
+ .title {
115
+ font-size: 1rem;
116
+ font-weight: 600;
117
+ color: hsl(var(--foreground, 240 10% 3.9%));
118
+ }
119
+
120
+ .subtitle {
121
+ display: block;
122
+ font-size: 0.85rem;
123
+ color: color-mix(in srgb, currentColor, transparent 35%);
124
+ margin-top: 0.1rem;
125
+ }
126
+
127
+ .metric {
128
+ font-size: 0.85rem;
129
+ font-weight: 600;
130
+ padding: 0.15rem 0.55rem;
131
+ border-radius: 999px;
132
+ background: rgba(0, 0, 0, 0.06);
133
+ color: inherit;
134
+ }
135
+ }
136
+
137
+ &__cta {
138
+ width: 36px;
139
+ height: 36px;
140
+ border-radius: 999px;
141
+ display: inline-flex;
142
+ align-items: center;
143
+ justify-content: center;
144
+ background: rgba(255, 255, 255, 0.65);
145
+ box-shadow: 0 10px 20px rgba(15, 15, 15, 0.12);
146
+ }
147
+
148
+ .helper {
149
+ margin: 0.25rem 0 0;
150
+ font-size: 0.85rem;
151
+ color: color-mix(in srgb, currentColor, transparent 40%);
152
+ }
153
+
154
+ &.tone-success {
155
+ .react-cupertino-ui-quick-action__media {
156
+ background: color-mix(in srgb, var(--color-green, #34c759), transparent 30%);
157
+ }
158
+ }
159
+
160
+ &.tone-warning {
161
+ .react-cupertino-ui-quick-action__media {
162
+ background: color-mix(in srgb, #ff9f0a, transparent 35%);
163
+ }
164
+ }
165
+
166
+ &.tone-danger {
167
+ .react-cupertino-ui-quick-action__media {
168
+ background: color-mix(in srgb, var(--color-red, #ff3b30), transparent 30%);
169
+ }
170
+ }
171
+
172
+ &.tone-indigo {
173
+ .react-cupertino-ui-quick-action__media {
174
+ background: color-mix(in srgb, #7c3aed, transparent 25%);
175
+ }
176
+ }
177
+ }
178
+
179
+ @media (prefers-reduced-motion: reduce) {
180
+ .react-cupertino-ui-quick-action {
181
+ transition: none;
182
+ }
183
+ }
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@react-cupertino-ui/quick-action",
3
+ "version": "0.0.0",
4
+ "description": "QuickAction tiles inspired by iOS quick actions",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "files": [
10
+ "dist"
11
+ ],
12
+ "sideEffects": [
13
+ "./dist/**/*.css",
14
+ "./dist/**/*.scss"
15
+ ],
16
+ "scripts": {
17
+ "build": "tsc -p tsconfig.build.json && npm run build:styles",
18
+ "build:styles": "node ../../../scripts/build-styles.mjs"
19
+ },
20
+ "peerDependencies": {
21
+ "react": "^18.3.1",
22
+ "react-dom": "^18.3.1"
23
+ },
24
+ "dependencies": {
25
+ "@react-cupertino-ui/shared": "0.0.0",
26
+ "lucide-react": "^0.417.0"
27
+ },
28
+ "devDependencies": {
29
+ "typescript": "^5.2.2"
30
+ },
31
+ "gitHead": "a6b07a7a8a0ab6f4c80884b6fb9d5eb16ee6da1d",
32
+ "publishConfig": {
33
+ "access": "public"
34
+ }
35
+ }