@purpurds/grid 4.6.0 → 5.1.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.
@@ -1,62 +0,0 @@
1
- @import "@purpurds/tokens/breakpoint/variables";
2
-
3
- $columns: 12;
4
-
5
- @mixin validate-col-numbers($noOfCols) {
6
- @if not(type-of($noOfCols) == "number") {
7
- @error 'Invalid col value type "#{type-of($noOfCols)}"';
8
- }
9
- @if ($noOfCols < 1 or $noOfCols > 12) {
10
- @error 'Invalid col value #{$noOfCols}, col number should be from 1 to 12';
11
- }
12
- }
13
-
14
- @mixin purpur-col($noOfCols: 1) {
15
- --padding-col: var(--purpur-spacing-gutter-sm);
16
-
17
- @include validate-col-numbers($noOfCols);
18
- box-sizing: border-box;
19
- display: block;
20
- padding-left: calc(var(--padding-col) / 2);
21
- padding-right: calc(var(--padding-col) / 2);
22
- width: calc(((100% - 1px) / #{$columns}) * #{$noOfCols});
23
-
24
- @media screen and (min-width: #{$purpur-breakpoint-md}) {
25
- --padding-col: var(--purpur-spacing-gutter-md);
26
- }
27
- @media screen and (min-width: #{$purpur-breakpoint-lg}) {
28
- --padding-col: var(--purpur-spacing-gutter-lg);
29
- }
30
- }
31
-
32
- @mixin purpur-col-md($noOfCols: 1) {
33
- @media screen and (min-width: #{$purpur-breakpoint-md}) {
34
- @include validate-col-numbers($noOfCols);
35
- width: calc(((100% - 1px) / #{$columns}) * #{$noOfCols});
36
- }
37
- }
38
-
39
- @mixin purpur-col-lg($noOfCols: 1) {
40
- @media screen and (min-width: #{$purpur-breakpoint-lg}) {
41
- @include validate-col-numbers($noOfCols);
42
- width: calc(((100% - 1px) / #{$columns}) * #{$noOfCols});
43
- }
44
- }
45
-
46
- .purpur-col {
47
- @for $i from 12 through 1 {
48
- &.purpur-col-#{$i} {
49
- @include purpur-col($i);
50
- }
51
- @media screen and (min-width: #{$purpur-breakpoint-md}) {
52
- &.purpur-col-md-#{$i} {
53
- @include purpur-col-md($i);
54
- }
55
- }
56
- @media screen and (min-width: #{$purpur-breakpoint-lg}) {
57
- &.purpur-col-lg-#{$i} {
58
- @include purpur-col-lg($i);
59
- }
60
- }
61
- }
62
- }
package/src/col.tsx DELETED
@@ -1,43 +0,0 @@
1
- import React, { ReactNode } from "react";
2
- import c from "classnames";
3
-
4
- import styles from "./col.module.scss";
5
-
6
- export type ColumnWidthType = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
7
-
8
- export type ColProps = {
9
- children: ReactNode;
10
- className?: string;
11
- ["data-testid"]?: string;
12
- width?: ColumnWidthType;
13
- widthMd?: ColumnWidthType;
14
- widthLg?: ColumnWidthType;
15
- };
16
-
17
- const rootClassName = "purpur-col";
18
-
19
- export const Col = ({
20
- children,
21
- ["data-testid"]: dataTestId,
22
- width,
23
- className,
24
- widthMd,
25
- widthLg,
26
- ...props
27
- }: ColProps) => {
28
- const classes = c([
29
- className,
30
- styles[rootClassName],
31
- {
32
- [styles[`${rootClassName}-${width}`]]: width,
33
- [styles[`${rootClassName}-md-${widthMd}`]]: widthMd,
34
- [styles[`${rootClassName}-lg-${widthLg}`]]: widthLg,
35
- },
36
- ]);
37
-
38
- return (
39
- <div className={`${classes} ${rootClassName}`} data-testid={dataTestId} {...props}>
40
- {children}
41
- </div>
42
- );
43
- };
@@ -1,79 +0,0 @@
1
- import React from "react";
2
- import type { Meta, StoryObj } from "@storybook/react";
3
-
4
- import { Grid } from "./grid";
5
-
6
- const meta: Meta<typeof Grid.Col> = {
7
- title: "Components/Grid",
8
- component: Grid.Col,
9
- parameters: {
10
- design: [
11
- {
12
- name: "Grid",
13
- type: "figma",
14
- url:
15
- "https://www.figma.com/file/2QIcZVqP99ZKY4rNW7VuSx/Purpur-DS---Foundations-Library?type=design&node-id=5704%3A10669&mode=design&t=lPtp9KR80NhTNx9u-1",
16
- },
17
- ],
18
- storyHead: {
19
- title: "Grid.Col",
20
- },
21
- },
22
- argTypes: {
23
- ["data-testid"]: { control: { type: "text" } },
24
- className: { control: { type: "text" } },
25
- children: { control: { type: "text" } },
26
- width: { control: { type: "range", min: 1, max: 12, step: 1 } },
27
- widthMd: { control: { type: "range", min: 1, max: 12, step: 1 } },
28
- widthLg: { control: { type: "range", min: 1, max: 12, step: 1 } },
29
- },
30
- };
31
- export default meta;
32
-
33
- type Story = StoryObj<typeof Grid.Col>;
34
-
35
- export const Column: Story = {
36
- args: {
37
- width: 12,
38
- widthMd: 12,
39
- widthLg: 12,
40
- },
41
- render: ({ children, ...args }) => (
42
- <Grid>
43
- <Grid.Row>
44
- <Grid.Col {...args}>
45
- <p>Column 1</p>
46
- {children}
47
- </Grid.Col>
48
- <Grid.Col {...args}>
49
- <p>Column 2</p>
50
- {children}
51
- </Grid.Col>
52
- <Grid.Col {...args}>
53
- <p>Column 3</p>
54
- {children}
55
- </Grid.Col>
56
- <Grid.Col {...args}>
57
- <p>Column 4</p>
58
- {children}
59
- </Grid.Col>
60
- <Grid.Col {...args}>
61
- <p>Column 5</p>
62
- {children}
63
- </Grid.Col>
64
- <Grid.Col {...args}>
65
- <p>Column 6</p>
66
- {children}
67
- </Grid.Col>
68
- <Grid.Col {...args}>
69
- <p>Column 7</p>
70
- {children}
71
- </Grid.Col>
72
- <Grid.Col {...args}>
73
- <p>Column 8</p>
74
- {children}
75
- </Grid.Col>
76
- </Grid.Row>
77
- </Grid>
78
- ),
79
- };
@@ -1,67 +0,0 @@
1
- /* eslint-disable react/prop-types */
2
- import React from "react";
3
- import type { Meta, StoryObj } from "@storybook/react";
4
-
5
- import { Grid } from "./grid";
6
- import { RowSpacingSizes } from "./row";
7
-
8
- const meta: Meta<typeof Grid.Row> = {
9
- title: "Components/Grid",
10
- component: Grid.Row,
11
- parameters: {
12
- design: [
13
- {
14
- name: "Grid",
15
- type: "figma",
16
- url:
17
- "https://www.figma.com/file/2QIcZVqP99ZKY4rNW7VuSx/Purpur-DS---Foundations-Library?type=design&node-id=5704%3A10669&mode=design&t=lPtp9KR80NhTNx9u-1",
18
- },
19
- ],
20
- storyHead: {
21
- title: "Grid.Row",
22
- },
23
- },
24
- argTypes: {
25
- ["data-testid"]: { control: { type: "text" } },
26
- className: { control: { type: "text" } },
27
- children: { control: { type: "text" } },
28
- colGap: { control: { type: "boolean" } },
29
- spacing: {
30
- control: { type: "select" },
31
- options: [undefined, ...RowSpacingSizes],
32
- },
33
- },
34
- };
35
- export default meta;
36
-
37
- type Story = StoryObj<typeof Grid.Row>;
38
-
39
- export const Row: Story = {
40
- args: {
41
- colGap: false,
42
- },
43
- render: ({ children, ...args }) => (
44
- <Grid>
45
- <Grid.Row {...args}>
46
- <Grid.Col width={12} widthMd={6} widthLg={4}>
47
- <p>Column 1 - Row 1</p>
48
- {children}
49
- </Grid.Col>
50
- <Grid.Col width={12} widthMd={6} widthLg={4}>
51
- <p>Column 2 - Row 1</p>
52
- {children}
53
- </Grid.Col>
54
- </Grid.Row>
55
- <Grid.Row {...args}>
56
- <Grid.Col width={12} widthMd={6} widthLg={4}>
57
- <p>Column 3 - Row 2</p>
58
- {children}
59
- </Grid.Col>
60
- <Grid.Col width={12} widthMd={6} widthLg={4}>
61
- <p>Column 4 - Row 2</p>
62
- {children}
63
- </Grid.Col>
64
- </Grid.Row>
65
- </Grid>
66
- ),
67
- };
@@ -1,58 +0,0 @@
1
- @import "@purpurds/tokens/breakpoint/variables";
2
-
3
- .purpur-row {
4
- --margin: var(--purpur-spacing-gutter-sm);
5
-
6
- box-sizing: border-box;
7
- display: flex;
8
- flex-wrap: wrap;
9
- justify-content: left;
10
- margin-left: calc(-1 * var(--margin) / 2);
11
- margin-right: calc(-1 * var(--margin) / 2);
12
-
13
- @media screen and (min-width: #{$purpur-breakpoint-md}) {
14
- --margin: var(--purpur-spacing-gutter-md);
15
- }
16
- @media screen and (min-width: #{$purpur-breakpoint-lg}) {
17
- --margin: var(--purpur-spacing-gutter-lg);
18
- }
19
- @media screen and (min-width: #{$purpur-breakpoint-xl}) {
20
- --margin: var(--purpur-spacing-gutter-xl);
21
- }
22
-
23
- &:last-of-type {
24
- margin-bottom: 0;
25
- }
26
-
27
- &--sm {
28
- margin-bottom: var(--purpur-spacing-gutter-sm);
29
- }
30
-
31
- &--md {
32
- margin-bottom: var(--purpur-spacing-gutter-md);
33
- }
34
-
35
- &--lg {
36
- margin-bottom: var(--purpur-spacing-gutter-md);
37
-
38
- @media screen and (min-width: #{$purpur-breakpoint-lg}) {
39
- margin-bottom: var(--purpur-spacing-gutter-lg);
40
- }
41
- }
42
-
43
- &--col-gap {
44
- margin-top: calc(-1 * var(--purpur-spacing-gutter-sm));
45
-
46
- @media screen and (min-width: #{$purpur-breakpoint-md}) {
47
- margin-top: calc(-1 * var(--purpur-spacing-gutter-md));
48
- }
49
-
50
- > :global(.purpur-col) {
51
- margin-top: var(--purpur-spacing-gutter-sm);
52
-
53
- @media screen and (min-width: #{$purpur-breakpoint-md}) {
54
- margin-top: var(--purpur-spacing-gutter-md);
55
- }
56
- }
57
- }
58
- }
package/src/row.tsx DELETED
@@ -1,47 +0,0 @@
1
- import React, { ReactNode } from "react";
2
- import c from "classnames";
3
-
4
- import styles from "./row.module.scss";
5
-
6
- export const RowSpacings = {
7
- SM: "sm",
8
- MD: "md",
9
- LG: "lg",
10
- } as const;
11
-
12
- export const RowSpacingSizes = Object.values(RowSpacings);
13
- export type RowSpacingsType = (typeof RowSpacings)[keyof typeof RowSpacings];
14
-
15
- export type RowProps = {
16
- className?: string;
17
- colGap?: boolean;
18
- ["data-testid"]?: string;
19
- children: ReactNode;
20
- spacing?: RowSpacingsType;
21
- };
22
-
23
- const rootClassName = "purpur-row";
24
-
25
- export const Row = ({
26
- children,
27
- ["data-testid"]: dataTestId,
28
- spacing,
29
- className,
30
- colGap,
31
- ...props
32
- }: RowProps) => {
33
- const classes = c([
34
- className,
35
- styles[rootClassName],
36
- {
37
- [styles[`${rootClassName}--${spacing}`]]: spacing,
38
- [styles[`${rootClassName}--col-gap`]]: colGap,
39
- },
40
- ]);
41
-
42
- return (
43
- <div className={classes} data-testid={dataTestId} {...props}>
44
- {children}
45
- </div>
46
- );
47
- };