react-justified-layout-ts 1.1.1 → 1.1.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.
@@ -82,6 +82,7 @@ function TSJustifiedLayout({ children, layoutItems, itemSpacing = 10, rowSpacing
82
82
  }
83
83
  const rows = [];
84
84
  let rowBuffer = [];
85
+ console.log(rows);
85
86
  layoutItems.forEach((value) => {
86
87
  const isItemSuccessfullyAdded = addItem(value);
87
88
  if (!isItemSuccessfullyAdded) {
@@ -89,26 +90,26 @@ function TSJustifiedLayout({ children, layoutItems, itemSpacing = 10, rowSpacing
89
90
  }
90
91
  });
91
92
  // Handle leftover content
93
+ console.log(rows);
92
94
  if (showWidows) {
93
95
  rows.push({ items: rowBuffer, height: rows.length === 0 ? targetRowHeight : rows[rows.length - 1].height });
94
96
  }
95
97
  let childNodeCounter = -1;
96
98
  /**
97
99
  * Clone the children element, and inject the height of the element as a prop
98
- * @param height The height that the element should be
100
+ * @param isLast If the element belongs to the last row, and therefore should use height instead of flex
99
101
  */
100
- function renderChildren(height) {
102
+ function renderChildren(isLast) {
101
103
  childNodeCounter++;
102
- return (0, react_1.cloneElement)(children[childNodeCounter], Object.assign(Object.assign({}, children[childNodeCounter].props), { style: Object.assign(Object.assign({}, children[childNodeCounter].props.style), { height: height }) }));
104
+ return (0, react_1.cloneElement)(children[childNodeCounter], Object.assign(Object.assign({}, children[childNodeCounter].props), { style: Object.assign(Object.assign(Object.assign({}, children[childNodeCounter].props.style), { maxWidth: '100%' }), (isLast ? { maxHeight: '100%' } : {})) }));
103
105
  }
104
106
  return (react_1.default.createElement(react_1.default.Fragment, null,
105
- react_1.default.createElement("div", { style: { width: "100%" } }, rows.map(value => {
106
- return react_1.default.createElement("div", { style: {
107
- display: "flex",
108
- flexDirection: "row",
109
- gap: itemSpacing,
110
- marginBottom: rowSpacing
111
- } }, value.items.map(() => react_1.default.createElement("div", { style: { height: value.height } }, renderChildren(value.height))));
107
+ react_1.default.createElement("div", { style: { width: "100%" } }),
108
+ react_1.default.createElement("div", { style: { width: "100%" } }, rows.map((value, index, array) => {
109
+ let isLastRow = index === array.length - 1 && showWidows;
110
+ return react_1.default.createElement("div", { style: Object.assign({ display: "flex", flexDirection: "row", gap: itemSpacing, marginBottom: rowSpacing }, (isLastRow ? { height: value.height } : {})) }, value.items.map((aspectRatio) => {
111
+ return react_1.default.createElement("div", { style: isLastRow ? { aspectRatio: aspectRatio } : { flex: aspectRatio } }, renderChildren(isLastRow));
112
+ }));
112
113
  }))));
113
114
  }
114
115
  exports.TSJustifiedLayout = TSJustifiedLayout;
package/package.json CHANGED
@@ -1,44 +1,29 @@
1
- {
2
- "name": "react-justified-layout-ts",
3
- "version": "1.1.1",
4
- "description": "A component based off Flickr's justified layout that is compatible with Typescript",
5
- "main": "./dist/TSJustifiedLayout.js",
6
- "types": "./dist/TSJustifiedLayout.d.ts",
7
- "files": [
8
- "dist"
9
- ],
10
- "scripts": {
11
- "test": "echo \"Error: no test specified\" && exit 1",
12
- "typescript": "tsc",
13
- "storybook": "storybook dev -p 6006",
14
- "build-storybook": "storybook build"
15
- },
16
- "keywords": [],
17
- "author": "Alan19",
18
- "license": "MIT",
19
- "dependencies": {
20
- "@types/node": "^20.10.7",
21
- "react-use": "^17.5.0",
22
- "react-use-measure": "^2.1.1"
23
- },
24
- "devDependencies": {
25
- "@chromatic-com/storybook": "^1.5.0",
26
- "@storybook/addon-essentials": "^8.1.5",
27
- "@storybook/addon-interactions": "^8.1.5",
28
- "@storybook/addon-links": "^8.1.5",
29
- "@storybook/addon-onboarding": "^8.1.5",
30
- "@storybook/addon-webpack5-compiler-swc": "^1.0.3",
31
- "@storybook/blocks": "^8.1.5",
32
- "@storybook/react": "^8.1.5",
33
- "@storybook/react-webpack5": "^8.1.5",
34
- "@storybook/test": "^8.1.5",
35
- "@types/react": "^18.2.47",
36
- "react": "^18.2.0",
37
- "storybook": "^8.1.5",
38
- "typescript": "^5.3.3"
39
- },
40
- "peerDependencies": {
41
- "react": "^18.2.0"
42
- },
43
- "repository": "https://github.com/Alan19/react-justified-layout-ts"
44
- }
1
+ {
2
+ "name": "react-justified-layout-ts",
3
+ "version": "1.1.2",
4
+ "description": "A component based off Flickr's justified layout that is compatible with Typescript",
5
+ "main": "./dist/TSJustifiedLayout.js",
6
+ "types": "./dist/TSJustifiedLayout.d.ts",
7
+ "files": [
8
+ "dist"
9
+ ],
10
+ "scripts": {
11
+ "test": "echo \"Error: no test specified\" && exit 1",
12
+ "typescript": "tsc"
13
+ },
14
+ "keywords": [],
15
+ "author": "Alan19",
16
+ "license": "MIT",
17
+ "dependencies": {
18
+ "@types/node": "^20.10.7"
19
+ },
20
+ "devDependencies": {
21
+ "@types/react": "^18.2.47",
22
+ "react": "^18.2.0",
23
+ "typescript": "^5.3.3"
24
+ },
25
+ "peerDependencies": {
26
+ "react": "^18.2.0"
27
+ },
28
+ "repository": "https://github.com/Alan19/react-justified-layout-ts"
29
+ }
@@ -1 +0,0 @@
1
- {"version":3,"file":"TSJustifiedLayout.d.ts","sourceRoot":"","sources":["../src/components/TSJustifiedLayout/TSJustifiedLayout.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAE1C,MAAM,WAAW,sBAAsB;IACnC,MAAM,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC9C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,GAAG,EAAE,CAAC;IAChB,UAAU,CAAC,EAAE,OAAO,CAAC;CAIxB;AAED,iBAAS,iBAAiB,CAAC,EACW,QAAQ,EACR,MAAM,EACN,WAAgB,EAChB,UAAe,EACf,UAAiB,EACjB,eAAqB,EACrB,wBAA8B,EAC9B,KAAK,EACR,EAAE,sBAAsB,qBA4G1D;AAED,OAAO,EAAC,iBAAiB,EAAC,CAAA"}
@@ -1,14 +0,0 @@
1
- import React from "react";
2
- type ElementDimensions = number;
3
- export interface TSJustifiedLayoutProps {
4
- layoutItems: ElementDimensions[];
5
- itemSpacing?: number;
6
- rowSpacing?: number;
7
- targetRowHeight?: number;
8
- targetRowHeightTolerance?: number;
9
- width: number;
10
- children: any[];
11
- showWidows?: boolean;
12
- }
13
- declare function TSJustifiedLayout({ children, layoutItems, itemSpacing, rowSpacing, showWidows, targetRowHeight, targetRowHeightTolerance, width }: TSJustifiedLayoutProps): React.JSX.Element;
14
- export { TSJustifiedLayout };
@@ -1,115 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.TSJustifiedLayout = void 0;
27
- const react_1 = __importStar(require("react"));
28
- function TSJustifiedLayout({ children, layoutItems, itemSpacing = 10, rowSpacing = 10, showWidows = true, targetRowHeight = 320, targetRowHeightTolerance = .25, width }) {
29
- const minAspectRatio = width / targetRowHeight * (1 - targetRowHeightTolerance);
30
- const maxAspectRatio = width / targetRowHeight * (1 + targetRowHeightTolerance);
31
- /**
32
- *
33
- * @param value The new aspect ratio to be checked
34
- * @return If the buffer can accept the new value
35
- * */
36
- function addItem(value) {
37
- const newItems = rowBuffer.concat(value);
38
- const newAspectRatio = newItems.map(dimensions => dimensions).reduce((previousValue, currentValue) => previousValue + currentValue, 0);
39
- const rowWidthWithoutSpacing = width - (newItems.length - 1) * itemSpacing;
40
- const targetAspectRatio = rowWidthWithoutSpacing / targetRowHeight;
41
- // Row still has space
42
- if (newAspectRatio < minAspectRatio) {
43
- rowBuffer.push(value);
44
- return true;
45
- }
46
- // Row ran out of space, and the new item is larger than the max aspect ratio for the row
47
- else if (newAspectRatio > maxAspectRatio) {
48
- // Always accept if it's just 1 item
49
- if (rowBuffer.length === 0) {
50
- rowBuffer.push(value);
51
- rows.push({ items: rowBuffer, height: rowWidthWithoutSpacing / newAspectRatio });
52
- rowBuffer = [];
53
- return true;
54
- }
55
- else {
56
- // Calculate width/aspect ratio for row before adding new item
57
- const previousRowWidthWithoutSpacing = width - (rowBuffer.length - 1) * itemSpacing;
58
- const previousAspectRatio = rowBuffer.map(dimensions => dimensions).reduce((previousValue, currentValue) => previousValue + currentValue, 0);
59
- const previousTargetAspectRatio = previousRowWidthWithoutSpacing / targetRowHeight;
60
- // If the new aspect ratio is farther from the target after the insert, then push row buffer and insert new item into the next row
61
- if (Math.abs(newAspectRatio - targetAspectRatio) > Math.abs(previousAspectRatio - previousTargetAspectRatio)) {
62
- rows.push({ items: rowBuffer, height: previousRowWidthWithoutSpacing / previousAspectRatio });
63
- rowBuffer = [];
64
- return false;
65
- }
66
- // If the new aspect ratio is closer to the target aspect ratio, then insert item and push row buffer
67
- else {
68
- rowBuffer.push(value);
69
- rows.push({ items: rowBuffer, height: rowWidthWithoutSpacing / newAspectRatio });
70
- rowBuffer = [];
71
- return true;
72
- }
73
- }
74
- }
75
- else {
76
- // New aspect ratio is within aspect ratio tolerance, so we finish off the row
77
- rowBuffer.push(value);
78
- rows.push({ items: rowBuffer, height: rowWidthWithoutSpacing / newAspectRatio });
79
- rowBuffer = [];
80
- return true;
81
- }
82
- }
83
- const rows = [];
84
- let rowBuffer = [];
85
- console.log(rows);
86
- layoutItems.forEach((value) => {
87
- const isItemSuccessfullyAdded = addItem(value);
88
- if (!isItemSuccessfullyAdded) {
89
- addItem(value);
90
- }
91
- });
92
- // Handle leftover content
93
- console.log(rows);
94
- if (showWidows) {
95
- rows.push({ items: rowBuffer, height: rows.length === 0 ? targetRowHeight : rows[rows.length - 1].height });
96
- }
97
- let childNodeCounter = -1;
98
- /**
99
- * Clone the children element, and inject the height of the element as a prop
100
- * @param isLast If the element belongs to the last row, and therefore should use height instead of flex
101
- */
102
- function renderChildren(isLast) {
103
- childNodeCounter++;
104
- return (0, react_1.cloneElement)(children[childNodeCounter], Object.assign(Object.assign({}, children[childNodeCounter].props), { style: Object.assign(Object.assign(Object.assign({}, children[childNodeCounter].props.style), { maxWidth: '100%' }), (isLast ? { maxHeight: '100%' } : {})) }));
105
- }
106
- return (react_1.default.createElement(react_1.default.Fragment, null,
107
- react_1.default.createElement("div", { style: { width: "100%" } }),
108
- react_1.default.createElement("div", { style: { width: "100%" } }, rows.map((value, index, array) => {
109
- let isLastRow = index === array.length - 1 && showWidows;
110
- return react_1.default.createElement("div", { style: Object.assign({ display: "flex", flexDirection: "row", gap: itemSpacing, marginBottom: rowSpacing }, (isLastRow ? { height: value.height } : {})) }, value.items.map((aspectRatio) => {
111
- return react_1.default.createElement("div", { style: isLastRow ? { aspectRatio: aspectRatio } : { flex: aspectRatio } }, renderChildren(isLastRow));
112
- }));
113
- }))));
114
- }
115
- exports.TSJustifiedLayout = TSJustifiedLayout;
@@ -1,29 +0,0 @@
1
- import React from 'react';
2
- import './button.css';
3
- interface ButtonProps {
4
- /**
5
- * Is this the principal call to action on the page?
6
- */
7
- primary?: boolean;
8
- /**
9
- * What background color to use
10
- */
11
- backgroundColor?: string;
12
- /**
13
- * How large should the button be?
14
- */
15
- size?: 'small' | 'medium' | 'large';
16
- /**
17
- * Button contents
18
- */
19
- label: string;
20
- /**
21
- * Optional click handler
22
- */
23
- onClick?: () => void;
24
- }
25
- /**
26
- * Primary UI component for user interaction
27
- */
28
- export declare const Button: ({ primary, size, backgroundColor, label, ...props }: ButtonProps) => React.JSX.Element;
29
- export {};
@@ -1,28 +0,0 @@
1
- "use strict";
2
- var __rest = (this && this.__rest) || function (s, e) {
3
- var t = {};
4
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
- t[p] = s[p];
6
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
- t[p[i]] = s[p[i]];
10
- }
11
- return t;
12
- };
13
- var __importDefault = (this && this.__importDefault) || function (mod) {
14
- return (mod && mod.__esModule) ? mod : { "default": mod };
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.Button = void 0;
18
- const react_1 = __importDefault(require("react"));
19
- require("./button.css");
20
- /**
21
- * Primary UI component for user interaction
22
- */
23
- const Button = (_a) => {
24
- var { primary = false, size = 'medium', backgroundColor, label } = _a, props = __rest(_a, ["primary", "size", "backgroundColor", "label"]);
25
- const mode = primary ? 'storybook-button--primary' : 'storybook-button--secondary';
26
- return (react_1.default.createElement("button", Object.assign({ type: "button", className: ['storybook-button', `storybook-button--${size}`, mode].join(' '), style: { backgroundColor } }, props), label));
27
- };
28
- exports.Button = Button;
@@ -1,54 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Warning = exports.Small = exports.Large = exports.Secondary = exports.Primary = void 0;
4
- const test_1 = require("@storybook/test");
5
- const Button_1 = require("./Button");
6
- // More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
7
- const meta = {
8
- title: 'Example/Button',
9
- component: Button_1.Button,
10
- parameters: {
11
- // Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout
12
- layout: 'centered',
13
- },
14
- // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
15
- tags: ['autodocs'],
16
- // More on argTypes: https://storybook.js.org/docs/api/argtypes
17
- argTypes: {
18
- backgroundColor: { control: 'color' },
19
- },
20
- // Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked: https://storybook.js.org/docs/essentials/actions#action-args
21
- args: { onClick: (0, test_1.fn)() },
22
- };
23
- exports.default = meta;
24
- // More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
25
- exports.Primary = {
26
- args: {
27
- primary: true,
28
- label: 'Button',
29
- },
30
- };
31
- exports.Secondary = {
32
- args: {
33
- label: 'Button',
34
- },
35
- };
36
- exports.Large = {
37
- args: {
38
- size: 'large',
39
- label: 'Button',
40
- },
41
- };
42
- exports.Small = {
43
- args: {
44
- size: 'small',
45
- label: 'Button',
46
- },
47
- };
48
- exports.Warning = {
49
- args: {
50
- primary: true,
51
- label: 'Delete now',
52
- backgroundColor: 'red',
53
- }
54
- };
@@ -1,3 +0,0 @@
1
- import { TSJustifiedLayoutProps } from "../components/TSJustifiedLayout/TSJustifiedLayout";
2
- import React from "react";
3
- export declare const ConfiguredJustifiedLayout: ({ layoutItems, rowSpacing, width, itemSpacing, targetRowHeight, targetRowHeightTolerance, showWidows, ...props }: TSJustifiedLayoutProps) => React.JSX.Element;
@@ -1,90 +0,0 @@
1
- "use strict";
2
- var __rest = (this && this.__rest) || function (s, e) {
3
- var t = {};
4
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
- t[p] = s[p];
6
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
- t[p[i]] = s[p[i]];
10
- }
11
- return t;
12
- };
13
- var __importDefault = (this && this.__importDefault) || function (mod) {
14
- return (mod && mod.__esModule) ? mod : { "default": mod };
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.ConfiguredJustifiedLayout = void 0;
18
- const TSJustifiedLayout_1 = require("../components/TSJustifiedLayout/TSJustifiedLayout");
19
- const react_1 = __importDefault(require("react"));
20
- const displayedImages = [
21
- {
22
- "tags": [
23
- "Eclipse Deity"
24
- ],
25
- "href": "",
26
- "aspectRatio": 0.8243310619910255,
27
- "parent": "Eclipse Deity v3",
28
- "thumbnailUrl": "https://alcorsiteartbucket.s3.amazonaws.com/600h/eclipse_deity_v3/0.webp",
29
- "webp": "https://alcorsiteartbucket.s3.amazonaws.com/webp/eclipse_deity_v3/0.webp",
30
- "src": "https://alcorsiteartbucket.s3.amazonaws.com/eclipse_deity_v3/0.png"
31
- },
32
- {
33
- "title": "Biogenesis Suit Design",
34
- "artist": "@EmberWickArt",
35
- "tags": [
36
- "Superhero",
37
- "Bodysuit"
38
- ],
39
- "href": "https://x.com/EmberWickArt/status/1795127025331577256",
40
- "published": "2024-05-27",
41
- "aspectRatio": 1.0115606936416186,
42
- "thumbnailUrl": "https://alcorsiteartbucket.s3.amazonaws.com/600h/biogenesis_suit_design.webp",
43
- "webp": "https://alcorsiteartbucket.s3.amazonaws.com/webp/biogenesis_suit_design.webp",
44
- "src": "https://alcorsiteartbucket.s3.amazonaws.com/biogenesis_suit_design.png"
45
- },
46
- {
47
- "title": "Alan and Alcor",
48
- "artist": "@kongzorim",
49
- "tags": [
50
- "Aldhibah Form",
51
- "Rastaban Form",
52
- "Standard Outfit"
53
- ],
54
- "href": "https://x.com/kongzorim/status/1795818089080385818",
55
- "published": "2024-05-29",
56
- "aspectRatio": 0.7056150600454398,
57
- "thumbnailUrl": "https://alcorsiteartbucket.s3.amazonaws.com/600h/alan_and_alcor.webp",
58
- "webp": "https://alcorsiteartbucket.s3.amazonaws.com/webp/alan_and_alcor.webp",
59
- "src": "https://alcorsiteartbucket.s3.amazonaws.com/alan_and_alcor.png"
60
- },
61
- {
62
- "tags": [
63
- ""
64
- ],
65
- "href": "",
66
- "aspectRatio": 1.7777777777777777,
67
- "parent": "Proud Summer Beach YCH",
68
- "thumbnailUrl": "https://alcorsiteartbucket.s3.amazonaws.com/600h/proud_summer_beach_ych/0.webp",
69
- "webp": "https://alcorsiteartbucket.s3.amazonaws.com/webp/proud_summer_beach_ych/0.webp",
70
- "src": "https://alcorsiteartbucket.s3.amazonaws.com/proud_summer_beach_ych/0.png"
71
- },
72
- {
73
- "title": "Soma's Spring Outfit",
74
- "artist": "@kaerukbin",
75
- "tags": [
76
- "Soma"
77
- ],
78
- "href": "https://skeb.jp/@kaerukbin/works/4",
79
- "published": "2024-05-31",
80
- "aspectRatio": 0.763189448441247,
81
- "thumbnailUrl": "https://alcorsiteartbucket.s3.amazonaws.com/600h/soma_s_spring_outfit.webp",
82
- "webp": "https://alcorsiteartbucket.s3.amazonaws.com/webp/soma_s_spring_outfit.webp",
83
- "src": "https://alcorsiteartbucket.s3.amazonaws.com/soma_s_spring_outfit.png"
84
- }
85
- ];
86
- const ConfiguredJustifiedLayout = (_a) => {
87
- var { layoutItems = displayedImages.map(value => value.aspectRatio), rowSpacing = 8, width = 1000, itemSpacing = 8, targetRowHeight = 320, targetRowHeightTolerance = 0.10, showWidows = true } = _a, props = __rest(_a, ["layoutItems", "rowSpacing", "width", "itemSpacing", "targetRowHeight", "targetRowHeightTolerance", "showWidows"]);
88
- return react_1.default.createElement(TSJustifiedLayout_1.TSJustifiedLayout, Object.assign({ layoutItems: displayedImages.map(value => value.aspectRatio), width: width, itemSpacing: itemSpacing, targetRowHeight: 320, targetRowHeightTolerance: targetRowHeightTolerance, rowSpacing: rowSpacing, showWidows: showWidows }, props), displayedImages.map(value => react_1.default.createElement("img", { alt: value.title, src: value.webp })));
89
- };
90
- exports.ConfiguredJustifiedLayout = ConfiguredJustifiedLayout;
@@ -1,13 +0,0 @@
1
- import React from 'react';
2
- import './header.css';
3
- type User = {
4
- name: string;
5
- };
6
- interface HeaderProps {
7
- user?: User;
8
- onLogin?: () => void;
9
- onLogout?: () => void;
10
- onCreateAccount?: () => void;
11
- }
12
- export declare const Header: ({ user, onLogin, onLogout, onCreateAccount }: HeaderProps) => React.JSX.Element;
13
- export {};
@@ -1,27 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Header = void 0;
7
- const react_1 = __importDefault(require("react"));
8
- const Button_1 = require("./Button");
9
- require("./header.css");
10
- const Header = ({ user, onLogin, onLogout, onCreateAccount }) => (react_1.default.createElement("header", null,
11
- react_1.default.createElement("div", { className: "storybook-header" },
12
- react_1.default.createElement("div", null,
13
- react_1.default.createElement("svg", { width: "32", height: "32", viewBox: "0 0 32 32", xmlns: "http://www.w3.org/2000/svg" },
14
- react_1.default.createElement("g", { fill: "none", fillRule: "evenodd" },
15
- react_1.default.createElement("path", { d: "M10 0h12a10 10 0 0110 10v12a10 10 0 01-10 10H10A10 10 0 010 22V10A10 10 0 0110 0z", fill: "#FFF" }),
16
- react_1.default.createElement("path", { d: "M5.3 10.6l10.4 6v11.1l-10.4-6v-11zm11.4-6.2l9.7 5.5-9.7 5.6V4.4z", fill: "#555AB9" }),
17
- react_1.default.createElement("path", { d: "M27.2 10.6v11.2l-10.5 6V16.5l10.5-6zM15.7 4.4v11L6 10l9.7-5.5z", fill: "#91BAF8" }))),
18
- react_1.default.createElement("h1", null, "Acme")),
19
- react_1.default.createElement("div", null, user ? (react_1.default.createElement(react_1.default.Fragment, null,
20
- react_1.default.createElement("span", { className: "welcome" },
21
- "Welcome, ",
22
- react_1.default.createElement("b", null, user.name),
23
- "!"),
24
- react_1.default.createElement(Button_1.Button, { size: "small", onClick: onLogout, label: "Log out" }))) : (react_1.default.createElement(react_1.default.Fragment, null,
25
- react_1.default.createElement(Button_1.Button, { size: "small", onClick: onLogin, label: "Log in" }),
26
- react_1.default.createElement(Button_1.Button, { primary: true, size: "small", onClick: onCreateAccount, label: "Sign up" })))))));
27
- exports.Header = Header;
@@ -1,29 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LoggedOut = exports.LoggedIn = void 0;
4
- const test_1 = require("@storybook/test");
5
- const Header_1 = require("./Header");
6
- const meta = {
7
- title: 'Example/Header',
8
- component: Header_1.Header,
9
- // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
10
- tags: ['autodocs'],
11
- parameters: {
12
- // More on how to position stories at: https://storybook.js.org/docs/configure/story-layout
13
- layout: 'fullscreen',
14
- },
15
- args: {
16
- onLogin: (0, test_1.fn)(),
17
- onLogout: (0, test_1.fn)(),
18
- onCreateAccount: (0, test_1.fn)(),
19
- },
20
- };
21
- exports.default = meta;
22
- exports.LoggedIn = {
23
- args: {
24
- user: {
25
- name: 'Jane Doe',
26
- },
27
- },
28
- };
29
- exports.LoggedOut = {};
@@ -1,9 +0,0 @@
1
- /// <reference types="react" />
2
- import type { StoryObj } from "@storybook/react";
3
- declare const meta: {
4
- title: string;
5
- component: ({ layoutItems, rowSpacing, width, itemSpacing, targetRowHeight, targetRowHeightTolerance, showWidows, ...props }: import("../components/TSJustifiedLayout/TSJustifiedLayout").TSJustifiedLayoutProps) => import("react").JSX.Element;
6
- };
7
- export default meta;
8
- type Story = StoryObj<typeof meta>;
9
- export declare const Primary: Story;
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Primary = void 0;
4
- const ConfiguredJustifiedLayout_1 = require("./ConfiguredJustifiedLayout");
5
- const meta = {
6
- title: 'JustifiedLayout/Basic',
7
- component: ConfiguredJustifiedLayout_1.ConfiguredJustifiedLayout,
8
- };
9
- exports.default = meta;
10
- // More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
11
- exports.Primary = {
12
- args: {
13
- width: 906,
14
- showWidows: true
15
- },
16
- };
@@ -1,3 +0,0 @@
1
- import React from 'react';
2
- import './page.css';
3
- export declare const Page: React.FC;
@@ -1,44 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Page = void 0;
7
- const react_1 = __importDefault(require("react"));
8
- const Header_1 = require("./Header");
9
- require("./page.css");
10
- const Page = () => {
11
- const [user, setUser] = react_1.default.useState();
12
- return (react_1.default.createElement("article", null,
13
- react_1.default.createElement(Header_1.Header, { user: user, onLogin: () => setUser({ name: 'Jane Doe' }), onLogout: () => setUser(undefined), onCreateAccount: () => setUser({ name: 'Jane Doe' }) }),
14
- react_1.default.createElement("section", { className: "storybook-page" },
15
- react_1.default.createElement("h2", null, "Pages in Storybook"),
16
- react_1.default.createElement("p", null,
17
- "We recommend building UIs with a",
18
- ' ',
19
- react_1.default.createElement("a", { href: "https://componentdriven.org", target: "_blank", rel: "noopener noreferrer" },
20
- react_1.default.createElement("strong", null, "component-driven")),
21
- ' ',
22
- "process starting with atomic components and ending with pages."),
23
- react_1.default.createElement("p", null, "Render pages with mock data. This makes it easy to build and review page states without needing to navigate to them in your app. Here are some handy patterns for managing page data in Storybook:"),
24
- react_1.default.createElement("ul", null,
25
- react_1.default.createElement("li", null, "Use a higher-level connected component. Storybook helps you compose such data from the \"args\" of child component stories"),
26
- react_1.default.createElement("li", null, "Assemble data in the page component from your services. You can mock these services out using Storybook.")),
27
- react_1.default.createElement("p", null,
28
- "Get a guided tutorial on component-driven development at",
29
- ' ',
30
- react_1.default.createElement("a", { href: "https://storybook.js.org/tutorials/", target: "_blank", rel: "noopener noreferrer" }, "Storybook tutorials"),
31
- ". Read more in the",
32
- ' ',
33
- react_1.default.createElement("a", { href: "https://storybook.js.org/docs", target: "_blank", rel: "noopener noreferrer" }, "docs"),
34
- "."),
35
- react_1.default.createElement("div", { className: "tip-wrapper" },
36
- react_1.default.createElement("span", { className: "tip" }, "Tip"),
37
- " Adjust the width of the canvas with the",
38
- ' ',
39
- react_1.default.createElement("svg", { width: "10", height: "10", viewBox: "0 0 12 12", xmlns: "http://www.w3.org/2000/svg" },
40
- react_1.default.createElement("g", { fill: "none", fillRule: "evenodd" },
41
- react_1.default.createElement("path", { d: "M1.5 5.2h4.8c.3 0 .5.2.5.4v5.1c-.1.2-.3.3-.4.3H1.4a.5.5 0 01-.5-.4V5.7c0-.3.2-.5.5-.5zm0-2.1h6.9c.3 0 .5.2.5.4v7a.5.5 0 01-1 0V4H1.5a.5.5 0 010-1zm0-2.1h9c.3 0 .5.2.5.4v9.1a.5.5 0 01-1 0V2H1.5a.5.5 0 010-1zm4.3 5.2H2V10h3.8V6.2z", id: "a", fill: "#999" }))),
42
- "Viewports addon in the toolbar"))));
43
- };
44
- exports.Page = Page;
@@ -1,13 +0,0 @@
1
- /// <reference types="react" />
2
- import type { StoryObj } from '@storybook/react';
3
- declare const meta: {
4
- title: string;
5
- component: import("react").FC<{}>;
6
- parameters: {
7
- layout: string;
8
- };
9
- };
10
- export default meta;
11
- type Story = StoryObj<typeof meta>;
12
- export declare const LoggedOut: Story;
13
- export declare const LoggedIn: Story;
@@ -1,36 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.LoggedIn = exports.LoggedOut = void 0;
13
- const test_1 = require("@storybook/test");
14
- const Page_1 = require("./Page");
15
- const meta = {
16
- title: 'Example/Page',
17
- component: Page_1.Page,
18
- parameters: {
19
- // More on how to position stories at: https://storybook.js.org/docs/configure/story-layout
20
- layout: 'fullscreen',
21
- },
22
- };
23
- exports.default = meta;
24
- exports.LoggedOut = {};
25
- // More on interaction testing: https://storybook.js.org/docs/writing-tests/interaction-testing
26
- exports.LoggedIn = {
27
- play: ({ canvasElement }) => __awaiter(void 0, void 0, void 0, function* () {
28
- const canvas = (0, test_1.within)(canvasElement);
29
- const loginButton = canvas.getByRole('button', { name: /Log in/i });
30
- yield (0, test_1.expect)(loginButton).toBeInTheDocument();
31
- yield test_1.userEvent.click(loginButton);
32
- yield (0, test_1.expect)(loginButton).not.toBeInTheDocument();
33
- const logoutButton = canvas.getByRole('button', { name: /Log out/i });
34
- yield (0, test_1.expect)(logoutButton).toBeInTheDocument();
35
- }),
36
- };