@obosbbl/grunnmuren-react 2.0.0-canary.49 → 2.0.0-canary.50
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/dist/index.d.mts +2 -1
- package/dist/index.mjs +80 -13
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -578,6 +578,7 @@ type CardProps = VariantProps<typeof cardVariants> & {
|
|
|
578
578
|
};
|
|
579
579
|
declare const cardVariants: (props?: ({
|
|
580
580
|
variant?: "subtle" | "outlined" | undefined;
|
|
581
|
+
layout?: "horizontal" | "vertical" | undefined;
|
|
581
582
|
} & ({
|
|
582
583
|
class?: cva.ClassValue;
|
|
583
584
|
className?: never;
|
|
@@ -585,7 +586,7 @@ declare const cardVariants: (props?: ({
|
|
|
585
586
|
class?: never;
|
|
586
587
|
className?: cva.ClassValue;
|
|
587
588
|
})) | undefined) => string;
|
|
588
|
-
declare const Card: ({ children, className: _className, variant, ...restProps }: CardProps) => react_jsx_runtime.JSX.Element;
|
|
589
|
+
declare const Card: ({ children, className: _className, variant, layout, ...restProps }: CardProps) => react_jsx_runtime.JSX.Element;
|
|
589
590
|
type CardLinkWrapperProps = {
|
|
590
591
|
children?: React.ReactNode;
|
|
591
592
|
className?: string;
|
package/dist/index.mjs
CHANGED
|
@@ -205,7 +205,8 @@ function Badge(props, ref) {
|
|
|
205
205
|
return /*#__PURE__*/ jsx("span", {
|
|
206
206
|
className: className,
|
|
207
207
|
...restProps,
|
|
208
|
-
ref: ref
|
|
208
|
+
ref: ref,
|
|
209
|
+
"data-slot": "badge"
|
|
209
210
|
});
|
|
210
211
|
}
|
|
211
212
|
const _Badge = /*#__PURE__*/ forwardRef(Badge);
|
|
@@ -1074,7 +1075,7 @@ const cardVariants = cva({
|
|
|
1074
1075
|
base: [
|
|
1075
1076
|
'group/card',
|
|
1076
1077
|
'rounded-2xl border p-3',
|
|
1077
|
-
'flex
|
|
1078
|
+
'flex gap-y-4',
|
|
1078
1079
|
'relative',
|
|
1079
1080
|
// **** Heading ****
|
|
1080
1081
|
'[&_[data-slot="heading"]]:inline',
|
|
@@ -1088,19 +1089,19 @@ const cardVariants = cva({
|
|
|
1088
1089
|
'[&_[data-slot="content"]]:flex [&_[data-slot="content"]]:flex-col [&_[data-slot="content"]]:gap-y-4',
|
|
1089
1090
|
// **** Media ****
|
|
1090
1091
|
'[&_[data-slot="media"]]:overflow-hidden',
|
|
1091
|
-
'[&_[data-slot="media"]]:
|
|
1092
|
+
'[&_[data-slot="media"]]:relative',
|
|
1092
1093
|
// Position media at the edges of the card (because of these negative margins the media-element must be a wrapper around the actual image or other media content)
|
|
1093
1094
|
'[&_[data-slot="media"]]:mx-[calc(theme(space.3)*-1-theme(borderWidth.DEFAULT))] [&_[data-slot="media"]]:mt-[calc(theme(space.3)*-1-theme(borderWidth.DEFAULT))]',
|
|
1094
1095
|
// Sets the aspect ratio of the media content (width: 100% is necessary to make aspect ratio work in FF)
|
|
1095
|
-
'[&_[data-slot="media"]
|
|
1096
|
+
'[&_[data-slot="media"]>*:not([data-slot="badge"])]:aspect-[3/2] [&_[data-slot="media"]>*:not([data-slot="badge"])]:w-full [&_[data-slot="media"]_img]:object-cover',
|
|
1096
1097
|
// Prepare zoom animation for hover effects. The hover effect can also be enabled by classes on the parent component, so it is always prepared here.
|
|
1097
1098
|
'[&_[data-slot="media"]>*]:duration-300 [&_[data-slot="media"]>*]:ease-in-out [&_[data-slot="media"]>*]:motion-safe:transition-transform',
|
|
1098
1099
|
// **** Card link ****
|
|
1099
1100
|
// **** Hover ****
|
|
1100
1101
|
// Enables the zoom hover effect on media (note that we can't use group-hover/card here, because there might be other clickable elements in the card aside from the heading)
|
|
1101
|
-
'[&:has([data-slot="card-link"]_a:hover)_[data-slot="media"]
|
|
1102
|
+
'[&:has([data-slot="card-link"]_a:hover)_[data-slot="media"]>*:not([data-slot="badge"])]:scale-110',
|
|
1102
1103
|
// **** Card link in Heading ****
|
|
1103
|
-
'[&:has([data-slot="heading"]_[data-slot="card-link"]:hover)_[data-slot="media"]
|
|
1104
|
+
'[&:has([data-slot="heading"]_[data-slot="card-link"]:hover)_[data-slot="media"]>*:not([data-slot="badge"])]:scale-110',
|
|
1104
1105
|
// Border (bottom/top) is set to transparent to make sure the bottom underline is not visible when the card is hovered
|
|
1105
1106
|
// Border top is set to even out the border bottom used for the underline
|
|
1106
1107
|
'[&_[data-slot="heading"]_[data-slot="card-link"]]:no-underline',
|
|
@@ -1122,7 +1123,23 @@ const cardVariants = cva({
|
|
|
1122
1123
|
'[&_[data-slot="card-link"]_a]:static',
|
|
1123
1124
|
// Place other interactive on top of the pseudo-element that makes the entire card clickable
|
|
1124
1125
|
// by setting a higher z-index than the pseudo-element (which implicitly z-index 0)
|
|
1125
|
-
'[&_a:not([data-slot="card-link"])]:z-[1] [&_button]:z-[1] [&_input]:z-[1]'
|
|
1126
|
+
'[&_a:not([data-slot="card-link"])]:z-[1] [&_button]:z-[1] [&_input]:z-[1]',
|
|
1127
|
+
// **** Badge ****
|
|
1128
|
+
'[&_[data-slot="media"]_[data-slot="badge"]]:absolute [&_[data-slot="media"]_[data-slot="badge"]]:top-0',
|
|
1129
|
+
// Increasing z-index Preserves badge position when media content is hovered (the transform scale effect might otherwise move the badge behind the other media content)
|
|
1130
|
+
'[&_[data-slot="media"]_[data-slot="badge"]]:z-[1]',
|
|
1131
|
+
// Left aligned - override default corner radius of the badge
|
|
1132
|
+
'[&_[data-slot="media"]_[data-slot="badge"]:first-child]:rounded-tl-2xl',
|
|
1133
|
+
'[&_[data-slot="media"]_[data-slot="badge"]:first-child]:rounded-br-2xl',
|
|
1134
|
+
'[&_[data-slot="media"]_[data-slot="badge"]:first-child]:rounded-tr-none',
|
|
1135
|
+
'[&_[data-slot="media"]_[data-slot="badge"]:first-child]:rounded-bl-none',
|
|
1136
|
+
// Right aligned - override default corner radius of the badge
|
|
1137
|
+
'[&_[data-slot="media"]_[data-slot="badge"]:last-child]:rounded-tl-none',
|
|
1138
|
+
'[&_[data-slot="media"]_[data-slot="badge"]:last-child]:rounded-br-none',
|
|
1139
|
+
'[&_[data-slot="media"]_[data-slot="badge"]:last-child]:rounded-tr-2xl',
|
|
1140
|
+
'[&_[data-slot="media"]_[data-slot="badge"]:last-child]:rounded-bl-2xl',
|
|
1141
|
+
// ... and position the badge at the right edge of the media content
|
|
1142
|
+
'[&_[data-slot="media"]_[data-slot="badge"]:last-child]:right-0'
|
|
1126
1143
|
],
|
|
1127
1144
|
variants: {
|
|
1128
1145
|
/**
|
|
@@ -1131,20 +1148,70 @@ const cardVariants = cva({
|
|
|
1131
1148
|
*/ variant: {
|
|
1132
1149
|
subtle: [
|
|
1133
1150
|
'border-transparent',
|
|
1134
|
-
// Media styles
|
|
1135
|
-
'[&_[data-slot="media"]]:rounded-
|
|
1151
|
+
// **** Media styles ****
|
|
1152
|
+
'[&_[data-slot="media"]]:rounded-2xl'
|
|
1136
1153
|
],
|
|
1137
1154
|
outlined: 'border border-black'
|
|
1155
|
+
},
|
|
1156
|
+
/**
|
|
1157
|
+
* The layout of the card
|
|
1158
|
+
* @default vertical
|
|
1159
|
+
*/ layout: {
|
|
1160
|
+
vertical: [
|
|
1161
|
+
'flex-col',
|
|
1162
|
+
// **** Media ****
|
|
1163
|
+
'[&_[data-slot="media"]]:rounded-t-2xl'
|
|
1164
|
+
],
|
|
1165
|
+
horizontal: [
|
|
1166
|
+
'gap-x-4',
|
|
1167
|
+
// **** With Media ****
|
|
1168
|
+
'[&:has(>[data-slot="media"]:first-child)]:flex-col',
|
|
1169
|
+
'[&:has(>[data-slot="media"]:last-child)]:flex-col-reverse',
|
|
1170
|
+
'[&:has(>[data-slot="media"])]:md:!flex-row',
|
|
1171
|
+
'[&:has(>[data-slot="media"])>*]:md:basis-1/2',
|
|
1172
|
+
// Position media at the edges of the card
|
|
1173
|
+
'[&_[data-slot="media"]]:md:mb-[calc(theme(space.3)*-1-theme(borderWidth.DEFAULT))]',
|
|
1174
|
+
'[&_[data-slot="media"]:first-child]:md:mr-0',
|
|
1175
|
+
'[&_[data-slot="media"]:last-child]:md:ml-0',
|
|
1176
|
+
// Make sure the card link is clickable when the media is on the right side
|
|
1177
|
+
// This i necessary because the media content is positioned after the card link in the DOM
|
|
1178
|
+
'[&:has(>[data-slot="media"]:last-child)_[data-slot="card-link"]]:z-[1]',
|
|
1179
|
+
// **** Without Media ****
|
|
1180
|
+
'[&:not(:has(>[data-slot="media"]))]:flex-row',
|
|
1181
|
+
// Make the layout responsive: when the Content reaches a minimum width of 18rem, the layout switches to vertical. Also makes sure Content takes up the remaining space available.
|
|
1182
|
+
'[&:not(:has(>[data-slot="media"]))]:flex-wrap [&:not(:has(>[data-slot="media"]))_[data-slot="content"]]:grow [&:not(:has(>[data-slot="media"]))_[data-slot="content"]]:basis-[18rem]',
|
|
1183
|
+
// Make sure svg's etc. are not shrinkable
|
|
1184
|
+
'[&>:not([data-slot="content"],[data-slot="media"])]:shrink-0'
|
|
1185
|
+
]
|
|
1138
1186
|
}
|
|
1139
1187
|
},
|
|
1140
1188
|
defaultVariants: {
|
|
1141
|
-
variant: 'subtle'
|
|
1142
|
-
|
|
1189
|
+
variant: 'subtle',
|
|
1190
|
+
layout: 'vertical'
|
|
1191
|
+
},
|
|
1192
|
+
compoundVariants: [
|
|
1193
|
+
{
|
|
1194
|
+
variant: 'outlined',
|
|
1195
|
+
layout: 'horizontal',
|
|
1196
|
+
className: [
|
|
1197
|
+
// **** Media ****
|
|
1198
|
+
// Some rounded corners are removed when the card is outlined
|
|
1199
|
+
'[&_[data-slot="media"]]:rounded-t-2xl',
|
|
1200
|
+
'[&_[data-slot="media"]:first-child]:md:rounded-tr-none [&_[data-slot="media"]:first-child]:md:rounded-bl-2xl',
|
|
1201
|
+
'[&_[data-slot="media"]:last-child]:md:rounded-tl-none [&_[data-slot="media"]:last-child]:md:rounded-br-2xl',
|
|
1202
|
+
// **** Badge ****
|
|
1203
|
+
// Override default corner radius of the badge to match the media border radius
|
|
1204
|
+
'[&_[data-slot="media"]:first-child_[data-slot="badge"]:last-child]:md:rounded-tr-none',
|
|
1205
|
+
'[&_[data-slot="media"]:last-child_[data-slot="badge"]:first-child]:md:rounded-tl-none'
|
|
1206
|
+
]
|
|
1207
|
+
}
|
|
1208
|
+
]
|
|
1143
1209
|
});
|
|
1144
|
-
const Card = ({ children, className: _className, variant, ...restProps })=>{
|
|
1210
|
+
const Card = ({ children, className: _className, variant, layout, ...restProps })=>{
|
|
1145
1211
|
const className = cardVariants({
|
|
1146
1212
|
className: _className,
|
|
1147
|
-
variant
|
|
1213
|
+
variant,
|
|
1214
|
+
layout
|
|
1148
1215
|
});
|
|
1149
1216
|
return /*#__PURE__*/ jsx("div", {
|
|
1150
1217
|
className: className,
|