@obosbbl/grunnmuren-react 3.8.1 → 3.8.2

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.
@@ -340,8 +340,11 @@ const variants = cva.cva({
340
340
  ],
341
341
  'full-bleed': [
342
342
  oneColumnLayout,
343
- // Position the media and carousel content to fill the entire viewport width
344
- '*:data-[slot=media]:*:absolute *:data-[slot=media]:*:left-0',
343
+ // Break media out to full viewport width — except the VideoLoop wrapper (`:has(video)`), which
344
+ // stays container-width so its play button anchors to the grid container (see the video rule below).
345
+ '*:data-[slot=media]:*:not-has-[video]:absolute *:data-[slot=media]:*:not-has-[video]:left-0',
346
+ // Break only the VideoLoop's video out to full width; the wrapper (and its button) stay in the container.
347
+ '**:data-[slot=video]:relative **:data-[slot=video]:left-1/2 **:data-[slot=video]:min-w-screen **:data-[slot=video]:-translate-x-1/2',
345
348
  // Special case for Carousel, where the Media is nested inside a CarouselItem
346
349
  '*:data-[slot=carousel]:**:data-[slot=media]:w-full',
347
350
  // Match the heights of the <Media> or <Carousel> wrapper for the Media content (e.g. image, VideoLoop, video etc.)
@@ -338,8 +338,11 @@ const variants = cva({
338
338
  ],
339
339
  'full-bleed': [
340
340
  oneColumnLayout,
341
- // Position the media and carousel content to fill the entire viewport width
342
- '*:data-[slot=media]:*:absolute *:data-[slot=media]:*:left-0',
341
+ // Break media out to full viewport width — except the VideoLoop wrapper (`:has(video)`), which
342
+ // stays container-width so its play button anchors to the grid container (see the video rule below).
343
+ '*:data-[slot=media]:*:not-has-[video]:absolute *:data-[slot=media]:*:not-has-[video]:left-0',
344
+ // Break only the VideoLoop's video out to full width; the wrapper (and its button) stay in the container.
345
+ '**:data-[slot=video]:relative **:data-[slot=video]:left-1/2 **:data-[slot=video]:min-w-screen **:data-[slot=video]:-translate-x-1/2',
343
346
  // Special case for Carousel, where the Media is nested inside a CarouselItem
344
347
  '*:data-[slot=carousel]:**:data-[slot=media]:w-full',
345
348
  // Match the heights of the <Media> or <Carousel> wrapper for the Media content (e.g. image, VideoLoop, video etc.)
package/dist/index.d.mts CHANGED
@@ -439,7 +439,7 @@ type HeadingProps = Omit<HTMLProps<HTMLHeadingElement>, 'size'> & VariantProps<t
439
439
  };
440
440
  declare const HeadingContext: react.Context<ContextValue<Partial<HeadingProps>, HTMLHeadingElement>>;
441
441
  declare const headingVariants: (props?: ({
442
- size?: "xl" | "l" | "m" | "s" | "xs" | undefined;
442
+ size?: "s" | "xl" | "l" | "m" | "xs" | undefined;
443
443
  } & ({
444
444
  class?: cva.ClassValue;
445
445
  className?: never;
package/dist/index.mjs CHANGED
@@ -426,6 +426,16 @@ const translations$1 = {
426
426
  nb: 'Fullført',
427
427
  sv: 'Slutförd',
428
428
  en: 'Completed'
429
+ },
430
+ playAnimation: {
431
+ nb: 'Spill av animasjon',
432
+ sv: 'Spela upp animation',
433
+ en: 'Play animation'
434
+ },
435
+ pauseAnimation: {
436
+ nb: 'Pause animasjon',
437
+ sv: 'Pausa animation',
438
+ en: 'Pause animation'
429
439
  }
430
440
  };
431
441
 
@@ -1238,8 +1248,11 @@ const variants = cva({
1238
1248
  ],
1239
1249
  'full-bleed': [
1240
1250
  oneColumnLayout,
1241
- // Position the media and carousel content to fill the entire viewport width
1242
- '*:data-[slot=media]:*:absolute *:data-[slot=media]:*:left-0',
1251
+ // Break media out to full viewport width — except the VideoLoop wrapper (`:has(video)`), which
1252
+ // stays container-width so its play button anchors to the grid container (see the video rule below).
1253
+ '*:data-[slot=media]:*:not-has-[video]:absolute *:data-[slot=media]:*:not-has-[video]:left-0',
1254
+ // Break only the VideoLoop's video out to full width; the wrapper (and its button) stay in the container.
1255
+ '**:data-[slot=video]:relative **:data-[slot=video]:left-1/2 **:data-[slot=video]:min-w-screen **:data-[slot=video]:-translate-x-1/2',
1243
1256
  // Special case for Carousel, where the Media is nested inside a CarouselItem
1244
1257
  '*:data-[slot=carousel]:**:data-[slot=media]:w-full',
1245
1258
  // Match the heights of the <Media> or <Carousel> wrapper for the Media content (e.g. image, VideoLoop, video etc.)
@@ -3639,19 +3652,23 @@ const VideoLoop = ({ src, format, alt, className })=>{
3639
3652
  }, [
3640
3653
  shouldPlay
3641
3654
  ]);
3655
+ const togglePlayback = ()=>setShouldPlay((prevState)=>!prevState);
3656
+ const locale = _useLocale();
3642
3657
  return /*#__PURE__*/ jsxs("div", {
3643
- className: cx(className, 'relative', prefersReducedMotion === null && 'opacity-0'),
3658
+ className: cx(className, // group: hover anywhere reveals the button. @container: corner placement only when large.
3659
+ 'group @container relative', prefersReducedMotion === null && 'opacity-0'),
3644
3660
  "data-slot": "video-loop",
3645
3661
  children: [
3646
3662
  /*#__PURE__*/ jsx("video", {
3647
3663
  "aria-hidden": true,
3648
3664
  ref: videoRef,
3649
- // cursor-pointer is not working on the button below, so we add it here for the same effect
3665
+ // Click anywhere on the video to toggle playback (in addition to the button)
3650
3666
  className: "size-full max-h-[inherit] cursor-pointer rounded-[inherit] object-cover",
3651
3667
  playsInline: true,
3652
3668
  loop: prefersReducedMotion === false,
3653
3669
  autoPlay: prefersReducedMotion === false,
3654
3670
  muted: true,
3671
+ onClick: togglePlayback,
3655
3672
  onEnded: (event)=>{
3656
3673
  if (prefersReducedMotion) {
3657
3674
  // Reset the video to the beginning if the user prefers reduced motion, since the video will not loop
@@ -3666,27 +3683,25 @@ const VideoLoop = ({ src, format, alt, className })=>{
3666
3683
  type: `video/${format}`
3667
3684
  })
3668
3685
  }),
3669
- prefersReducedMotion !== null && /*#__PURE__*/ jsx("button", {
3670
- "data-slot": "video-loop-button",
3671
- // oxlint-disable-next-line jsx-a11y/no-aria-hidden-on-focusable
3672
- "aria-hidden": true,
3673
- type: "button",
3674
- onClick: ()=>setShouldPlay((prevState)=>!prevState),
3675
- className: cx('absolute inset-0 m-auto grid place-items-center', 'focus-visible:outline-focus focus-visible:outline-focus-offset', 'rounded-[inherit]', // Setting the opacity to 0 before applying the transition below will ensure the button only fades in after the video has started playing
3686
+ alt && /*#__PURE__*/ jsx("p", {
3687
+ className: "sr-only",
3688
+ children: alt
3689
+ }),
3690
+ prefersReducedMotion !== null && /*#__PURE__*/ jsx(Button, {
3691
+ "aria-label": isPlaying ? translations$1.pauseAnimation[locale] : translations$1.playAnimation[locale],
3692
+ isIconOnly: true,
3693
+ variant: "primary",
3694
+ color: "white",
3695
+ onPress: togglePlayback,
3696
+ className: cx(// Centered in small containers; moved to the bottom-left corner in larger ones
3697
+ 'absolute inset-0 m-auto size-fit', '@md:inset-auto @md:bottom-4 @md:left-4', // Opacity-only transition; overrides Button's `transition-colors` so the focus outline doesn't flash black→white
3698
+ 'transition-opacity duration-200', // Start hidden so the button fades in once the video plays
3676
3699
  shouldPlay && 'opacity-0', isPlaying && [
3677
- 'transition-opacity duration-200',
3678
3700
  // Only show the pause button when the video is hovered or focused
3679
3701
  'focus-visible:opacity-100',
3680
- 'hover:opacity-100'
3702
+ 'group-hover:opacity-100'
3681
3703
  ]),
3682
- children: /*#__PURE__*/ jsx("span", {
3683
- className: "grid size-12 place-items-center rounded-full bg-white outline-hidden",
3684
- children: isPlaying ? /*#__PURE__*/ jsx(PlayerPause, {}) : /*#__PURE__*/ jsx(PlayerPlay, {})
3685
- })
3686
- }),
3687
- alt && /*#__PURE__*/ jsx("p", {
3688
- className: "sr-only",
3689
- children: alt
3704
+ children: isPlaying ? /*#__PURE__*/ jsx(PlayerPause, {}) : /*#__PURE__*/ jsx(PlayerPlay, {})
3690
3705
  })
3691
3706
  ]
3692
3707
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@obosbbl/grunnmuren-react",
3
- "version": "3.8.1",
3
+ "version": "3.8.2",
4
4
  "description": "Grunnmuren components in React",
5
5
  "license": "MIT",
6
6
  "repository": {