@react-cupertino-ui/card 1.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,156 @@
1
+ .react-cupertino-ui-card {
2
+ --card-glass-blur: var(--glass-blur, 32px);
3
+ --card-glass-opacity: var(--glass-opacity, 0.7);
4
+ --card-padding-block: 1.75rem;
5
+ --card-padding-inline: 1.5rem;
6
+ position: relative;
7
+ display: flex;
8
+ flex-direction: column;
9
+ width: 100%;
10
+ gap: 0.75rem;
11
+ padding: var(--card-padding-block) var(--card-padding-inline);
12
+ border-radius: 1.5rem;
13
+ border: 1px solid rgba(10, 10, 10, 0.04);
14
+ background: rgba(250, 250, 252, 0.9);
15
+ color: var(--foreground, #0a0a0a);
16
+ isolation: isolate;
17
+ overflow: hidden;
18
+ box-shadow: 0 1px 1px rgba(15, 15, 15, 0.06), 0 16px 40px rgba(15, 15, 15, 0.08);
19
+ transition-property: all;
20
+ transition-duration: var(--card-transition-duration, 320ms);
21
+ transition-timing-function: cubic-bezier(0.175, 0.885, 0.32, 1.275);
22
+ }
23
+ .react-cupertino-ui-card::after {
24
+ content: "";
25
+ position: absolute;
26
+ inset: 0;
27
+ background-image: var(--card-background-image);
28
+ background-size: cover;
29
+ background-position: center;
30
+ opacity: 0;
31
+ transition: opacity 320ms ease, filter 320ms ease;
32
+ z-index: 0;
33
+ mix-blend-mode: multiply;
34
+ }
35
+ .react-cupertino-ui-card > * {
36
+ position: relative;
37
+ z-index: 1;
38
+ }
39
+ .react-cupertino-ui-card:focus-visible {
40
+ outline: none;
41
+ box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.35), 0 10px 50px rgba(10, 10, 10, 0.18);
42
+ }
43
+ .react-cupertino-ui-card:focus {
44
+ outline: none;
45
+ }
46
+ @media (hover: hover) {
47
+ .react-cupertino-ui-card[data-interactive=true]:hover {
48
+ transform: translateY(-6px) scale(1.01);
49
+ box-shadow: 0 8px 18px rgba(9, 9, 9, 0.08), 0 30px 60px rgba(9, 9, 9, 0.15);
50
+ }
51
+ }
52
+ .react-cupertino-ui-card[data-interactive=true]:focus-visible {
53
+ transform: translateY(-2px) scale(1.005);
54
+ }
55
+ .react-cupertino-ui-card[data-has-background=true]::after {
56
+ opacity: 0.55;
57
+ filter: saturate(120%) contrast(105%);
58
+ }
59
+ .react-cupertino-ui-card[data-has-background=true]::before {
60
+ mix-blend-mode: screen;
61
+ }
62
+ .react-cupertino-ui-card.react-cupertino-ui-card--glass {
63
+ background: rgba(255, 255, 255, var(--card-glass-opacity));
64
+ backdrop-filter: blur(var(--card-glass-blur)) saturate(var(--glass-saturation, 180%));
65
+ -webkit-backdrop-filter: blur(var(--card-glass-blur)) saturate(var(--glass-saturation, 180%));
66
+ border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.18));
67
+ box-shadow: var(--glass-shadow, 0 8px 32px rgba(0, 0, 0, 0.12));
68
+ position: relative;
69
+ overflow: hidden;
70
+ }
71
+ .react-cupertino-ui-card.react-cupertino-ui-card--glass::before {
72
+ content: "";
73
+ position: absolute;
74
+ inset: 0;
75
+ background: var(--glass-highlight, linear-gradient(135deg, rgba(255, 255, 255, 0.4) 0%, transparent 55%));
76
+ border-radius: inherit;
77
+ opacity: var(--glass-highlight-opacity, 0.95);
78
+ pointer-events: none;
79
+ mix-blend-mode: screen;
80
+ }
81
+ @supports not (backdrop-filter: blur(2px)) {
82
+ .react-cupertino-ui-card.react-cupertino-ui-card--glass {
83
+ background: rgba(255, 255, 255, 0.92);
84
+ }
85
+ }
86
+ .react-cupertino-ui-card.react-cupertino-ui-card--media {
87
+ color: color-mix(in srgb, white 92%, rgba(0, 0, 0, 0.95));
88
+ text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
89
+ }
90
+ .react-cupertino-ui-card.react-cupertino-ui-card--media .react-cupertino-ui-card__muted,
91
+ .react-cupertino-ui-card.react-cupertino-ui-card--media p,
92
+ .react-cupertino-ui-card.react-cupertino-ui-card--media span {
93
+ color: color-mix(in srgb, white 88%, rgba(0, 0, 0, 0.5));
94
+ }
95
+ .react-cupertino-ui-card.variant-glass {
96
+ border: 1px solid rgba(255, 255, 255, 0.25);
97
+ }
98
+ .react-cupertino-ui-card.variant-default {
99
+ background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(245, 246, 248, 0.96));
100
+ border: 1px solid rgba(12, 12, 12, 0.08);
101
+ box-shadow: 0 10px 35px rgba(15, 15, 15, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.45);
102
+ }
103
+ .react-cupertino-ui-card.variant-solid {
104
+ background: linear-gradient(140deg, #0a84ff 0%, #30d158 45%, #5ac8fa 100%);
105
+ color: white;
106
+ border: 1px solid rgba(255, 255, 255, 0.35);
107
+ box-shadow: 0 20px 40px rgba(10, 132, 255, 0.3);
108
+ }
109
+ .react-cupertino-ui-card.variant-outline {
110
+ background: transparent;
111
+ border: 1px solid rgba(255, 255, 255, 0.45);
112
+ color: var(--foreground, #0a0a0a);
113
+ }
114
+ .react-cupertino-ui-card.variant-secondary {
115
+ background: rgba(0, 0, 0, 0.04);
116
+ border-color: rgba(0, 0, 0, 0.08);
117
+ box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
118
+ }
119
+ .react-cupertino-ui-card.variant-destructive {
120
+ background: color-mix(in srgb, var(--color-red, #ff3b30), white 15%);
121
+ color: white;
122
+ box-shadow: 0 25px 45px rgba(255, 59, 48, 0.35);
123
+ }
124
+ .react-cupertino-ui-card.variant-ghost {
125
+ background: transparent;
126
+ border-color: transparent;
127
+ }
128
+ .react-cupertino-ui-card.variant-link {
129
+ background: transparent;
130
+ border-color: transparent;
131
+ color: var(--color-blue, #0a84ff);
132
+ padding: 0;
133
+ }
134
+ .react-cupertino-ui-card.size-default {
135
+ --card-padding-block: 1.75rem;
136
+ --card-padding-inline: 1.5rem;
137
+ border-radius: 1.5rem;
138
+ }
139
+ .react-cupertino-ui-card.size-sm {
140
+ --card-padding-block: 1.25rem;
141
+ --card-padding-inline: 1.25rem;
142
+ border-radius: 1.25rem;
143
+ }
144
+ .react-cupertino-ui-card.size-lg {
145
+ --card-padding-block: 2rem;
146
+ --card-padding-inline: 2rem;
147
+ border-radius: 1.75rem;
148
+ }
149
+ .react-cupertino-ui-card.size-icon {
150
+ --card-padding-block: 1rem;
151
+ --card-padding-inline: 1rem;
152
+ align-items: center;
153
+ justify-content: center;
154
+ min-height: 5rem;
155
+ min-width: 5rem;
156
+ }
@@ -0,0 +1,36 @@
1
+ import * as React from "react";
2
+ import { BaseProps } from "@react-cupertino-ui/shared/lib/interfaces/BaseProps";
3
+ import glassTokens from "@react-cupertino-ui/shared/lib/constants/tokens/glass";
4
+ import "./index.scss";
5
+ type GlassBlur = keyof typeof glassTokens.blur;
6
+ export interface CardProps extends BaseProps<HTMLDivElement>, React.HTMLAttributes<HTMLDivElement> {
7
+ asChild?: boolean;
8
+ /**
9
+ * Enables the Liquid Glass visual treatment regardless of the variant prop.
10
+ */
11
+ glass?: boolean;
12
+ /**
13
+ * Controls the blur radius applied to the glass surface.
14
+ */
15
+ blur?: GlassBlur;
16
+ /**
17
+ * Adjusts surface opacity for the glass panel (0 - transparent, 1 - solid).
18
+ */
19
+ intensity?: number;
20
+ /**
21
+ * Optional background image that appears behind the glass overlay.
22
+ */
23
+ backgroundImage?: string;
24
+ /**
25
+ * Enables hover/focus elevation interactions.
26
+ */
27
+ interactive?: boolean;
28
+ }
29
+ declare const CardHeader: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
30
+ declare const CardTitle: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLHeadingElement> & React.RefAttributes<HTMLParagraphElement>>;
31
+ declare const CardDescription: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLParagraphElement> & React.RefAttributes<HTMLParagraphElement>>;
32
+ declare const CardContent: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
33
+ declare const CardFooter: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
34
+ declare const Card: React.ForwardRefExoticComponent<CardProps & React.RefAttributes<HTMLDivElement>>;
35
+ export { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent, };
36
+ export default Card;
package/dist/index.js ADDED
@@ -0,0 +1,51 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import * as React from "react";
3
+ import { Slot } from "@radix-ui/react-slot";
4
+ import { cn } from "@react-cupertino-ui/shared/lib/utils";
5
+ import { BaseVariants } from "@react-cupertino-ui/shared/lib/interfaces/BaseProps";
6
+ import glassTokens from "@react-cupertino-ui/shared/lib/constants/tokens/glass";
7
+ import "./index.scss";
8
+ const CardHeader = React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, className: cn("flex flex-col space-y-1.5 p-6", className), ...props })));
9
+ CardHeader.displayName = "CardHeader";
10
+ const CardTitle = React.forwardRef(({ className, ...props }, ref) => (_jsx("h3", { ref: ref, className: cn("text-2xl font-semibold leading-none tracking-tight", className), ...props })));
11
+ CardTitle.displayName = "CardTitle";
12
+ const CardDescription = React.forwardRef(({ className, ...props }, ref) => (_jsx("p", { ref: ref, className: cn("text-sm text-muted-foreground", className), ...props })));
13
+ CardDescription.displayName = "CardDescription";
14
+ const CardContent = React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, className: cn("p-6 pt-0", className), ...props })));
15
+ CardContent.displayName = "CardContent";
16
+ const CardFooter = React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, className: cn("flex items-center p-6 pt-0", className), ...props })));
17
+ CardFooter.displayName = "CardFooter";
18
+ const Card = React.forwardRef(({ className, variant, size, asChild = false, glass = true, blur = "md", intensity, backgroundImage, interactive = true, style, ...props }, ref) => {
19
+ const Comp = asChild ? Slot : "div";
20
+ const cssVars = {
21
+ ...style,
22
+ };
23
+ if (blur && glass) {
24
+ cssVars["--card-glass-blur"] = glassTokens.blur[blur];
25
+ }
26
+ if (typeof intensity === "number") {
27
+ const clamped = Math.min(Math.max(intensity, 0), 1);
28
+ cssVars["--card-glass-opacity"] = clamped.toString();
29
+ }
30
+ if (backgroundImage) {
31
+ const trimmed = backgroundImage.trim();
32
+ const isCssFunction = /^(url|linear-gradient|radial-gradient|conic-gradient)\(/i.test(trimmed);
33
+ cssVars["--card-background-image"] = isCssFunction
34
+ ? trimmed
35
+ : `url(${backgroundImage})`;
36
+ }
37
+ const resolvedVariant = variant ?? (glass ? "glass" : undefined);
38
+ const classes = BaseVariants("react-cupertino-ui-card", {
39
+ variant: resolvedVariant,
40
+ size,
41
+ className: cn(glass && "react-cupertino-ui-card--glass", backgroundImage && "react-cupertino-ui-card--media", className),
42
+ }, {
43
+ defaultVariants: {
44
+ variant: glass ? "glass" : "default",
45
+ },
46
+ });
47
+ return (_jsx(Comp, { ref: ref, className: cn(classes), style: cssVars, "data-glass": glass ? "true" : undefined, "data-interactive": interactive ? "true" : undefined, "data-has-background": backgroundImage ? "true" : undefined, ...props }));
48
+ });
49
+ Card.displayName = "Card";
50
+ export { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent, };
51
+ export default Card;
@@ -0,0 +1,174 @@
1
+ @use "@/styles/mixins/glass" as glass;
2
+ @use "@/styles/mixins/animations" as motion;
3
+
4
+ .react-cupertino-ui-card {
5
+ --card-glass-blur: var(--glass-blur, 32px);
6
+ --card-glass-opacity: var(--glass-opacity, 0.7);
7
+ --card-padding-block: 1.75rem;
8
+ --card-padding-inline: 1.5rem;
9
+ position: relative;
10
+ display: flex;
11
+ flex-direction: column;
12
+ width: 100%;
13
+ gap: 0.75rem;
14
+ padding: var(--card-padding-block) var(--card-padding-inline);
15
+ border-radius: 1.5rem;
16
+ border: 1px solid rgba(10, 10, 10, 0.04);
17
+ background: rgba(250, 250, 252, 0.9);
18
+ color: var(--foreground, #0a0a0a);
19
+ isolation: isolate;
20
+ overflow: hidden;
21
+ box-shadow:
22
+ 0 1px 1px rgba(15, 15, 15, 0.06),
23
+ 0 16px 40px rgba(15, 15, 15, 0.08);
24
+ @include motion.spring-transition(all, var(--card-transition-duration, 320ms));
25
+
26
+ &::after {
27
+ content: "";
28
+ position: absolute;
29
+ inset: 0;
30
+ background-image: var(--card-background-image);
31
+ background-size: cover;
32
+ background-position: center;
33
+ opacity: 0;
34
+ transition: opacity 320ms ease, filter 320ms ease;
35
+ z-index: 0;
36
+ mix-blend-mode: multiply;
37
+ }
38
+
39
+ > * {
40
+ position: relative;
41
+ z-index: 1;
42
+ }
43
+
44
+ &:focus-visible {
45
+ outline: none;
46
+ box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.35),
47
+ 0 10px 50px rgba(10, 10, 10, 0.18);
48
+ }
49
+
50
+ &:focus {
51
+ outline: none;
52
+ }
53
+
54
+ &[data-interactive="true"] {
55
+ @media (hover: hover) {
56
+ &:hover {
57
+ transform: translateY(-6px) scale(1.01);
58
+ box-shadow:
59
+ 0 8px 18px rgba(9, 9, 9, 0.08),
60
+ 0 30px 60px rgba(9, 9, 9, 0.15);
61
+ }
62
+ }
63
+
64
+ &:focus-visible {
65
+ transform: translateY(-2px) scale(1.005);
66
+ }
67
+ }
68
+
69
+ &[data-has-background="true"] {
70
+ &::after {
71
+ opacity: 0.55;
72
+ filter: saturate(120%) contrast(105%);
73
+ }
74
+
75
+ &::before {
76
+ mix-blend-mode: screen;
77
+ }
78
+ }
79
+
80
+ &.react-cupertino-ui-card--glass {
81
+ @include glass.glass-panel(light, var(--card-glass-blur), var(--card-glass-opacity));
82
+
83
+ @supports not ((backdrop-filter: blur(2px))) {
84
+ background: rgba(255, 255, 255, 0.92);
85
+ }
86
+ }
87
+
88
+ &.react-cupertino-ui-card--media {
89
+ color: color-mix(in srgb, white 92%, rgba(0, 0, 0, 0.95));
90
+ text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
91
+
92
+ .react-cupertino-ui-card__muted,
93
+ p,
94
+ span {
95
+ color: color-mix(in srgb, white 88%, rgba(0, 0, 0, 0.5));
96
+ }
97
+ }
98
+
99
+ &.variant-glass {
100
+ border: 1px solid rgba(255, 255, 255, 0.25);
101
+ }
102
+
103
+ &.variant-default {
104
+ background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(245, 246, 248, 0.96));
105
+ border: 1px solid rgba(12, 12, 12, 0.08);
106
+ box-shadow:
107
+ 0 10px 35px rgba(15, 15, 15, 0.08),
108
+ inset 0 1px 0 rgba(255, 255, 255, 0.45);
109
+ }
110
+
111
+ &.variant-solid {
112
+ background: linear-gradient(140deg, #0a84ff 0%, #30d158 45%, #5ac8fa 100%);
113
+ color: white;
114
+ border: 1px solid rgba(255, 255, 255, 0.35);
115
+ box-shadow: 0 20px 40px rgba(10, 132, 255, 0.3);
116
+ }
117
+
118
+ &.variant-outline {
119
+ background: transparent;
120
+ border: 1px solid rgba(255, 255, 255, 0.45);
121
+ color: var(--foreground, #0a0a0a);
122
+ }
123
+
124
+ &.variant-secondary {
125
+ background: rgba(0, 0, 0, 0.04);
126
+ border-color: rgba(0, 0, 0, 0.08);
127
+ box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
128
+ }
129
+
130
+ &.variant-destructive {
131
+ background: color-mix(in srgb, var(--color-red, #ff3b30), white 15%);
132
+ color: white;
133
+ box-shadow: 0 25px 45px rgba(255, 59, 48, 0.35);
134
+ }
135
+
136
+ &.variant-ghost {
137
+ background: transparent;
138
+ border-color: transparent;
139
+ }
140
+
141
+ &.variant-link {
142
+ background: transparent;
143
+ border-color: transparent;
144
+ color: var(--color-blue, #0a84ff);
145
+ padding: 0;
146
+ }
147
+
148
+ &.size-default {
149
+ --card-padding-block: 1.75rem;
150
+ --card-padding-inline: 1.5rem;
151
+ border-radius: 1.5rem;
152
+ }
153
+
154
+ &.size-sm {
155
+ --card-padding-block: 1.25rem;
156
+ --card-padding-inline: 1.25rem;
157
+ border-radius: 1.25rem;
158
+ }
159
+
160
+ &.size-lg {
161
+ --card-padding-block: 2rem;
162
+ --card-padding-inline: 2rem;
163
+ border-radius: 1.75rem;
164
+ }
165
+
166
+ &.size-icon {
167
+ --card-padding-block: 1rem;
168
+ --card-padding-inline: 1rem;
169
+ align-items: center;
170
+ justify-content: center;
171
+ min-height: 5rem;
172
+ min-width: 5rem;
173
+ }
174
+ }
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@react-cupertino-ui/card",
3
+ "version": "1.0.0",
4
+ "description": "Card component from React Cupertino UI",
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
+ "@radix-ui/react-slot": "^1.1.0",
26
+ "@react-cupertino-ui/shared": "workspace:*"
27
+ },
28
+ "devDependencies": {
29
+ "typescript": "^5.2.2"
30
+ },
31
+ "gitHead": "3f53987bdb936a331665691b517c2ba9984777f8",
32
+ "publishConfig": {
33
+ "access": "public"
34
+ }
35
+ }