Skip to content

Commit 737277b

Browse files
authored
Remove unordered list from Marquee & ensure we have no empty rows (#2035)
1 parent 007d7f6 commit 737277b

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

.changeset/giant-berries-draw.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@theguild/components": patch
3+
---
4+
5+
Remove unordered list from Marquee & ensure we have no empty rows

packages/components/src/components/marquee/index.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ export function Marquee({
4545
)}
4646
{...rest}
4747
>
48-
<ul
48+
<div
4949
className={cn(
50-
'flex w-max animate-[marquee_var(--animation-duration)_var(--animation-direction)_linear_infinite] gap-2 py-1',
50+
'flex w-max animate-[marquee_var(--animation-duration)_var(--animation-direction)_linear_infinite] gap-1 py-0.5 sm:gap-2 sm:py-1',
5151
)}
5252
style={
5353
{
@@ -75,7 +75,7 @@ export function Marquee({
7575
>
7676
{children}
7777
{children}
78-
</ul>
78+
</div>
7979
<style href="Marquee-keyframes">
8080
{
8181
/* css */ `
@@ -106,11 +106,15 @@ export function MarqueeRows({
106106
className,
107107
...rest
108108
}: MarqueeRowsProps) {
109-
const chunkSize = Math.ceil(children.length / rows);
109+
const chunkSize = Math.floor(children.length / rows);
110+
const remainder = children.length % rows;
110111
const chunks: ReactElement[][] = [];
111112

113+
let start = 0;
112114
for (let i = 0; i < rows; i++) {
113-
chunks.push(children.slice(i * chunkSize, (i + 1) * chunkSize));
115+
const end = start + chunkSize + (i < remainder ? 1 : 0); // distribute extras
116+
chunks.push(children.slice(start, end));
117+
start = end;
114118
}
115119

116120
return (

packages/components/src/components/marquee/marquee.stories.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { hiveThemeDecorator } from '../../../../../.storybook/hive-theme-decorat
33
import { Marquee, MarqueeProps, MarqueeRows, MarqueeRowsProps } from './index';
44

55
export default {
6-
title: 'Marquee',
6+
title: 'Components/Marquee',
77
component: Marquee,
88
decorators: [hiveThemeDecorator],
99
parameters: {
@@ -242,7 +242,7 @@ export const EnvelopPlugins: StoryObj<MarqueeRowsProps> = {
242242
href={plugin.href}
243243
target="_blank"
244244
rel="noreferrer"
245-
className="hive-focus rounded-lg bg-green-900 px-4 py-3 text-green-600 transition hover:bg-green-800 hover:text-white"
245+
className="hive-focus rounded bg-green-900 px-2 py-1.5 text-[10px] text-green-600 transition hover:bg-green-800 hover:text-white sm:rounded-lg sm:px-4 sm:py-3 sm:text-sm"
246246
>
247247
{plugin.title}
248248
</a>

0 commit comments

Comments
 (0)