@sproutsocial/seeds-react-content-block 0.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.
- package/.eslintignore +6 -0
- package/.eslintrc.js +4 -0
- package/.turbo/turbo-build.log +21 -0
- package/CHANGELOG.md +66 -0
- package/dist/esm/index.js +70 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/index.d.mts +16 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +107 -0
- package/dist/index.js.map +1 -0
- package/jest.config.js +9 -0
- package/package.json +47 -0
- package/src/ContentBlock.stories.tsx +52 -0
- package/src/ContentBlock.tsx +58 -0
- package/src/__tests__/content-block.test.tsx +53 -0
- package/src/index.ts +6 -0
- package/src/styled.d.ts +7 -0
- package/src/styles.ts +23 -0
- package/tsconfig.json +9 -0
- package/tsup.config.ts +12 -0
package/.eslintignore
ADDED
package/.eslintrc.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
yarn run v1.22.22
|
|
2
|
+
$ tsup --dts
|
|
3
|
+
[34mCLI[39m Building entry: src/index.ts
|
|
4
|
+
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
5
|
+
[34mCLI[39m tsup v8.5.0
|
|
6
|
+
[34mCLI[39m Using tsup config: /home/runner/work/seeds/seeds/seeds-react/seeds-react-content-block/tsup.config.ts
|
|
7
|
+
[34mCLI[39m Target: es2022
|
|
8
|
+
[34mCLI[39m Cleaning output folder
|
|
9
|
+
[34mCJS[39m Build start
|
|
10
|
+
[34mESM[39m Build start
|
|
11
|
+
[32mCJS[39m [1mdist/index.js [22m[32m4.44 KB[39m
|
|
12
|
+
[32mCJS[39m [1mdist/index.js.map [22m[32m4.05 KB[39m
|
|
13
|
+
[32mCJS[39m ⚡️ Build success in 113ms
|
|
14
|
+
[32mESM[39m [1mdist/esm/index.js [22m[32m2.24 KB[39m
|
|
15
|
+
[32mESM[39m [1mdist/esm/index.js.map [22m[32m4.00 KB[39m
|
|
16
|
+
[32mESM[39m ⚡️ Build success in 114ms
|
|
17
|
+
[34mDTS[39m Build start
|
|
18
|
+
[32mDTS[39m ⚡️ Build success in 28601ms
|
|
19
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m521.00 B[39m
|
|
20
|
+
[32mDTS[39m [1mdist/index.d.mts [22m[32m521.00 B[39m
|
|
21
|
+
Done in 35.71s.
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# @sproutsocial/seeds-react-content-block
|
|
2
|
+
|
|
3
|
+
## 0.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 1de0863: **Breaking Changes**
|
|
8
|
+
|
|
9
|
+
`@sproutsocial/seeds-react-container` has been simplified to a basic styled container component. It now only provides border, background, and border-radius styling as a wrapper around Box, accepting all Box props.
|
|
10
|
+
|
|
11
|
+
The previous Container component functionality (with title, subtitle, loading states, and header actions) has been moved to a new package: `@sproutsocial/seeds-react-content-block`.
|
|
12
|
+
|
|
13
|
+
**Migration**
|
|
14
|
+
|
|
15
|
+
If you were using the old Container component with `title`, `subtitle`, `isLoading`, or `headerActions` props, switch to `@sproutsocial/seeds-react-content-block`:
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
// Before
|
|
19
|
+
import { Container } from "@sproutsocial/seeds-react-container";
|
|
20
|
+
|
|
21
|
+
// After
|
|
22
|
+
import { ContentBlock } from "@sproutsocial/seeds-react-content-block";
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## 0.1.4
|
|
26
|
+
|
|
27
|
+
### Patch Changes
|
|
28
|
+
|
|
29
|
+
- @sproutsocial/seeds-react-icon@2.0.2
|
|
30
|
+
- @sproutsocial/seeds-react-button@1.3.7
|
|
31
|
+
|
|
32
|
+
## 0.1.3
|
|
33
|
+
|
|
34
|
+
### Patch Changes
|
|
35
|
+
|
|
36
|
+
- Updated dependencies [fa7579a]
|
|
37
|
+
- @sproutsocial/seeds-react-theme@3.2.1
|
|
38
|
+
- @sproutsocial/seeds-react-box@1.1.7
|
|
39
|
+
- @sproutsocial/seeds-react-icon@2.0.1
|
|
40
|
+
- @sproutsocial/seeds-react-loader@1.0.6
|
|
41
|
+
- @sproutsocial/seeds-react-button@1.3.6
|
|
42
|
+
|
|
43
|
+
## 0.1.2
|
|
44
|
+
|
|
45
|
+
### Patch Changes
|
|
46
|
+
|
|
47
|
+
- Updated dependencies [40248a0]
|
|
48
|
+
- @sproutsocial/seeds-react-icon@2.0.0
|
|
49
|
+
- @sproutsocial/seeds-react-button@1.3.5
|
|
50
|
+
|
|
51
|
+
## 0.1.1
|
|
52
|
+
|
|
53
|
+
### Patch Changes
|
|
54
|
+
|
|
55
|
+
- Updated dependencies [8f6ba8d]
|
|
56
|
+
- @sproutsocial/seeds-react-theme@3.2.0
|
|
57
|
+
- @sproutsocial/seeds-react-box@1.1.6
|
|
58
|
+
- @sproutsocial/seeds-react-icon@1.1.8
|
|
59
|
+
- @sproutsocial/seeds-react-loader@1.0.5
|
|
60
|
+
- @sproutsocial/seeds-react-button@1.3.4
|
|
61
|
+
|
|
62
|
+
## 0.1.0
|
|
63
|
+
|
|
64
|
+
### Minor Changes
|
|
65
|
+
|
|
66
|
+
- 5f6fee3: Created new component called Container that accepts a title, subtitle, header action, and can display a loading state"
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// src/ContentBlock.tsx
|
|
2
|
+
import "react";
|
|
3
|
+
import { Box as Box2 } from "@sproutsocial/seeds-react-box";
|
|
4
|
+
import { Text } from "@sproutsocial/seeds-react-text";
|
|
5
|
+
import { Loader } from "@sproutsocial/seeds-react-loader";
|
|
6
|
+
|
|
7
|
+
// src/styles.ts
|
|
8
|
+
import styled from "styled-components";
|
|
9
|
+
import { Box } from "@sproutsocial/seeds-react-box";
|
|
10
|
+
var ContentBlockStyles = styled.section`
|
|
11
|
+
background: ${({ theme }) => theme.colors.container.background.base};
|
|
12
|
+
border: ${({ theme }) => theme.borderWidths[500]} solid
|
|
13
|
+
${({ theme }) => theme.colors.container.border.base};
|
|
14
|
+
border-radius: ${({ theme }) => theme.radii.outer};
|
|
15
|
+
`;
|
|
16
|
+
var ContentBlockHeader = styled(Box)`
|
|
17
|
+
display: flex;
|
|
18
|
+
justify-content: space-between;
|
|
19
|
+
align-items: center;
|
|
20
|
+
border-bottom: ${({ theme }) => theme.borderWidths[500]} solid
|
|
21
|
+
${({ theme }) => theme.colors.container.border.base};
|
|
22
|
+
color: ${({ theme }) => theme.colors.text.headline};
|
|
23
|
+
padding: ${({ theme }) => theme.space[400]};
|
|
24
|
+
`;
|
|
25
|
+
var ContentBlockContent = styled(Box)`
|
|
26
|
+
padding: ${({ theme }) => theme.space[400]};
|
|
27
|
+
`;
|
|
28
|
+
|
|
29
|
+
// src/ContentBlock.tsx
|
|
30
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
31
|
+
var ContentBlock = ({
|
|
32
|
+
title,
|
|
33
|
+
subtitle,
|
|
34
|
+
titleAs = "h2",
|
|
35
|
+
subtitleAs = "h3",
|
|
36
|
+
content,
|
|
37
|
+
isLoading,
|
|
38
|
+
headerActions,
|
|
39
|
+
contentProps,
|
|
40
|
+
...boxProps
|
|
41
|
+
}) => {
|
|
42
|
+
return /* @__PURE__ */ jsxs(ContentBlockStyles, { as: "section", ...boxProps, children: [
|
|
43
|
+
/* @__PURE__ */ jsxs(ContentBlockHeader, { children: [
|
|
44
|
+
/* @__PURE__ */ jsxs(Box2, { children: [
|
|
45
|
+
/* @__PURE__ */ jsx(Text.Headline, { as: titleAs, children: title }),
|
|
46
|
+
/* @__PURE__ */ jsx(Text.Byline, { as: subtitleAs, fontWeight: "normal", children: subtitle })
|
|
47
|
+
] }),
|
|
48
|
+
headerActions && /* @__PURE__ */ jsx(Box2, { children: headerActions })
|
|
49
|
+
] }),
|
|
50
|
+
/* @__PURE__ */ jsx(
|
|
51
|
+
Box2,
|
|
52
|
+
{
|
|
53
|
+
p: 400,
|
|
54
|
+
...contentProps,
|
|
55
|
+
borderBottomLeftRadius: "outer",
|
|
56
|
+
borderBottomRightRadius: "outer",
|
|
57
|
+
children: isLoading ? /* @__PURE__ */ jsx(Box2, { my: 400, children: /* @__PURE__ */ jsx(Loader, { delay: false }) }) : content
|
|
58
|
+
}
|
|
59
|
+
)
|
|
60
|
+
] });
|
|
61
|
+
};
|
|
62
|
+
var ContentBlock_default = ContentBlock;
|
|
63
|
+
|
|
64
|
+
// src/index.ts
|
|
65
|
+
var index_default = ContentBlock_default;
|
|
66
|
+
export {
|
|
67
|
+
ContentBlock_default as ContentBlock,
|
|
68
|
+
index_default as default
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/ContentBlock.tsx","../../src/styles.ts","../../src/index.ts"],"sourcesContent":["import React from \"react\";\nimport { Box } from \"@sproutsocial/seeds-react-box\";\nimport { Text } from \"@sproutsocial/seeds-react-text\";\nimport { Loader } from \"@sproutsocial/seeds-react-loader\";\nimport { ContentBlockHeader, ContentBlockStyles } from \"./styles\";\n\nexport interface ContentBlockProps {\n title: string;\n subtitle: string;\n titleAs: \"h1\" | \"h2\" | \"h3\" | \"h4\";\n subtitleAs: \"h2\" | \"h3\" | \"h4\" | \"h5\" | \"p\";\n isLoading?: boolean;\n content?: React.ReactNode;\n headerActions?: React.ReactNode;\n contentProps?: React.ComponentProps<typeof Box>;\n}\n\nconst ContentBlock: React.FC<ContentBlockProps> = ({\n title,\n subtitle,\n titleAs = \"h2\",\n subtitleAs = \"h3\",\n content,\n isLoading,\n headerActions,\n contentProps,\n ...boxProps\n}) => {\n return (\n <ContentBlockStyles as=\"section\" {...boxProps}>\n <ContentBlockHeader>\n <Box>\n <Text.Headline as={titleAs}>{title}</Text.Headline>\n <Text.Byline as={subtitleAs} fontWeight=\"normal\">\n {subtitle}\n </Text.Byline>\n </Box>\n {headerActions && <Box>{headerActions}</Box>}\n </ContentBlockHeader>\n <Box\n p={400}\n {...contentProps}\n borderBottomLeftRadius=\"outer\"\n borderBottomRightRadius=\"outer\"\n >\n {isLoading ? (\n <Box my={400}>\n <Loader delay={false} />\n </Box>\n ) : (\n content\n )}\n </Box>\n </ContentBlockStyles>\n );\n};\n\nexport default ContentBlock;\n","import styled from \"styled-components\";\nimport { Box } from \"@sproutsocial/seeds-react-box\";\n\nexport const ContentBlockStyles = styled.section`\n background: ${({ theme }) => theme.colors.container.background.base};\n border: ${({ theme }) => theme.borderWidths[500]} solid\n ${({ theme }) => theme.colors.container.border.base};\n border-radius: ${({ theme }) => theme.radii.outer};\n`;\n\nexport const ContentBlockHeader = styled(Box)`\n display: flex;\n justify-content: space-between;\n align-items: center;\n border-bottom: ${({ theme }) => theme.borderWidths[500]} solid\n ${({ theme }) => theme.colors.container.border.base};\n color: ${({ theme }) => theme.colors.text.headline};\n padding: ${({ theme }) => theme.space[400]};\n`;\n\nexport const ContentBlockContent = styled(Box)`\n padding: ${({ theme }) => theme.space[400]};\n`;\n","import ContentBlock from \"./ContentBlock\";\n\nexport type { ContentBlockProps } from \"./ContentBlock\";\n\nexport default ContentBlock;\nexport { ContentBlock };\n"],"mappings":";AAAA,OAAkB;AAClB,SAAS,OAAAA,YAAW;AACpB,SAAS,YAAY;AACrB,SAAS,cAAc;;;ACHvB,OAAO,YAAY;AACnB,SAAS,WAAW;AAEb,IAAM,qBAAqB,OAAO;AAAA,gBACzB,CAAC,EAAE,MAAM,MAAM,MAAM,OAAO,UAAU,WAAW,IAAI;AAAA,YACzD,CAAC,EAAE,MAAM,MAAM,MAAM,aAAa,GAAG,CAAC;AAAA,MAC5C,CAAC,EAAE,MAAM,MAAM,MAAM,OAAO,UAAU,OAAO,IAAI;AAAA,mBACpC,CAAC,EAAE,MAAM,MAAM,MAAM,MAAM,KAAK;AAAA;AAG5C,IAAM,qBAAqB,OAAO,GAAG;AAAA;AAAA;AAAA;AAAA,mBAIzB,CAAC,EAAE,MAAM,MAAM,MAAM,aAAa,GAAG,CAAC;AAAA,MACnD,CAAC,EAAE,MAAM,MAAM,MAAM,OAAO,UAAU,OAAO,IAAI;AAAA,WAC5C,CAAC,EAAE,MAAM,MAAM,MAAM,OAAO,KAAK,QAAQ;AAAA,aACvC,CAAC,EAAE,MAAM,MAAM,MAAM,MAAM,GAAG,CAAC;AAAA;AAGrC,IAAM,sBAAsB,OAAO,GAAG;AAAA,aAChC,CAAC,EAAE,MAAM,MAAM,MAAM,MAAM,GAAG,CAAC;AAAA;;;ADUpC,SACE,KADF;AAdR,IAAM,eAA4C,CAAC;AAAA,EACjD;AAAA,EACA;AAAA,EACA,UAAU;AAAA,EACV,aAAa;AAAA,EACb;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AACJ,SACE,qBAAC,sBAAmB,IAAG,WAAW,GAAG,UACnC;AAAA,yBAAC,sBACC;AAAA,2BAACC,MAAA,EACC;AAAA,4BAAC,KAAK,UAAL,EAAc,IAAI,SAAU,iBAAM;AAAA,QACnC,oBAAC,KAAK,QAAL,EAAY,IAAI,YAAY,YAAW,UACrC,oBACH;AAAA,SACF;AAAA,MACC,iBAAiB,oBAACA,MAAA,EAAK,yBAAc;AAAA,OACxC;AAAA,IACA;AAAA,MAACA;AAAA,MAAA;AAAA,QACC,GAAG;AAAA,QACF,GAAG;AAAA,QACJ,wBAAuB;AAAA,QACvB,yBAAwB;AAAA,QAEvB,sBACC,oBAACA,MAAA,EAAI,IAAI,KACP,8BAAC,UAAO,OAAO,OAAO,GACxB,IAEA;AAAA;AAAA,IAEJ;AAAA,KACF;AAEJ;AAEA,IAAO,uBAAQ;;;AErDf,IAAO,gBAAQ;","names":["Box","Box"]}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Box } from '@sproutsocial/seeds-react-box';
|
|
3
|
+
|
|
4
|
+
interface ContentBlockProps {
|
|
5
|
+
title: string;
|
|
6
|
+
subtitle: string;
|
|
7
|
+
titleAs: "h1" | "h2" | "h3" | "h4";
|
|
8
|
+
subtitleAs: "h2" | "h3" | "h4" | "h5" | "p";
|
|
9
|
+
isLoading?: boolean;
|
|
10
|
+
content?: React.ReactNode;
|
|
11
|
+
headerActions?: React.ReactNode;
|
|
12
|
+
contentProps?: React.ComponentProps<typeof Box>;
|
|
13
|
+
}
|
|
14
|
+
declare const ContentBlock: React.FC<ContentBlockProps>;
|
|
15
|
+
|
|
16
|
+
export { ContentBlock, type ContentBlockProps, ContentBlock as default };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Box } from '@sproutsocial/seeds-react-box';
|
|
3
|
+
|
|
4
|
+
interface ContentBlockProps {
|
|
5
|
+
title: string;
|
|
6
|
+
subtitle: string;
|
|
7
|
+
titleAs: "h1" | "h2" | "h3" | "h4";
|
|
8
|
+
subtitleAs: "h2" | "h3" | "h4" | "h5" | "p";
|
|
9
|
+
isLoading?: boolean;
|
|
10
|
+
content?: React.ReactNode;
|
|
11
|
+
headerActions?: React.ReactNode;
|
|
12
|
+
contentProps?: React.ComponentProps<typeof Box>;
|
|
13
|
+
}
|
|
14
|
+
declare const ContentBlock: React.FC<ContentBlockProps>;
|
|
15
|
+
|
|
16
|
+
export { ContentBlock, type ContentBlockProps, ContentBlock as default };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
|
+
ContentBlock: () => ContentBlock_default,
|
|
34
|
+
default: () => index_default
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(index_exports);
|
|
37
|
+
|
|
38
|
+
// src/ContentBlock.tsx
|
|
39
|
+
var import_react = require("react");
|
|
40
|
+
var import_seeds_react_box2 = require("@sproutsocial/seeds-react-box");
|
|
41
|
+
var import_seeds_react_text = require("@sproutsocial/seeds-react-text");
|
|
42
|
+
var import_seeds_react_loader = require("@sproutsocial/seeds-react-loader");
|
|
43
|
+
|
|
44
|
+
// src/styles.ts
|
|
45
|
+
var import_styled_components = __toESM(require("styled-components"));
|
|
46
|
+
var import_seeds_react_box = require("@sproutsocial/seeds-react-box");
|
|
47
|
+
var ContentBlockStyles = import_styled_components.default.section`
|
|
48
|
+
background: ${({ theme }) => theme.colors.container.background.base};
|
|
49
|
+
border: ${({ theme }) => theme.borderWidths[500]} solid
|
|
50
|
+
${({ theme }) => theme.colors.container.border.base};
|
|
51
|
+
border-radius: ${({ theme }) => theme.radii.outer};
|
|
52
|
+
`;
|
|
53
|
+
var ContentBlockHeader = (0, import_styled_components.default)(import_seeds_react_box.Box)`
|
|
54
|
+
display: flex;
|
|
55
|
+
justify-content: space-between;
|
|
56
|
+
align-items: center;
|
|
57
|
+
border-bottom: ${({ theme }) => theme.borderWidths[500]} solid
|
|
58
|
+
${({ theme }) => theme.colors.container.border.base};
|
|
59
|
+
color: ${({ theme }) => theme.colors.text.headline};
|
|
60
|
+
padding: ${({ theme }) => theme.space[400]};
|
|
61
|
+
`;
|
|
62
|
+
var ContentBlockContent = (0, import_styled_components.default)(import_seeds_react_box.Box)`
|
|
63
|
+
padding: ${({ theme }) => theme.space[400]};
|
|
64
|
+
`;
|
|
65
|
+
|
|
66
|
+
// src/ContentBlock.tsx
|
|
67
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
68
|
+
var ContentBlock = ({
|
|
69
|
+
title,
|
|
70
|
+
subtitle,
|
|
71
|
+
titleAs = "h2",
|
|
72
|
+
subtitleAs = "h3",
|
|
73
|
+
content,
|
|
74
|
+
isLoading,
|
|
75
|
+
headerActions,
|
|
76
|
+
contentProps,
|
|
77
|
+
...boxProps
|
|
78
|
+
}) => {
|
|
79
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(ContentBlockStyles, { as: "section", ...boxProps, children: [
|
|
80
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(ContentBlockHeader, { children: [
|
|
81
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_seeds_react_box2.Box, { children: [
|
|
82
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_seeds_react_text.Text.Headline, { as: titleAs, children: title }),
|
|
83
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_seeds_react_text.Text.Byline, { as: subtitleAs, fontWeight: "normal", children: subtitle })
|
|
84
|
+
] }),
|
|
85
|
+
headerActions && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_seeds_react_box2.Box, { children: headerActions })
|
|
86
|
+
] }),
|
|
87
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
88
|
+
import_seeds_react_box2.Box,
|
|
89
|
+
{
|
|
90
|
+
p: 400,
|
|
91
|
+
...contentProps,
|
|
92
|
+
borderBottomLeftRadius: "outer",
|
|
93
|
+
borderBottomRightRadius: "outer",
|
|
94
|
+
children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_seeds_react_box2.Box, { my: 400, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_seeds_react_loader.Loader, { delay: false }) }) : content
|
|
95
|
+
}
|
|
96
|
+
)
|
|
97
|
+
] });
|
|
98
|
+
};
|
|
99
|
+
var ContentBlock_default = ContentBlock;
|
|
100
|
+
|
|
101
|
+
// src/index.ts
|
|
102
|
+
var index_default = ContentBlock_default;
|
|
103
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
104
|
+
0 && (module.exports = {
|
|
105
|
+
ContentBlock
|
|
106
|
+
});
|
|
107
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/ContentBlock.tsx","../src/styles.ts"],"sourcesContent":["import ContentBlock from \"./ContentBlock\";\n\nexport type { ContentBlockProps } from \"./ContentBlock\";\n\nexport default ContentBlock;\nexport { ContentBlock };\n","import React from \"react\";\nimport { Box } from \"@sproutsocial/seeds-react-box\";\nimport { Text } from \"@sproutsocial/seeds-react-text\";\nimport { Loader } from \"@sproutsocial/seeds-react-loader\";\nimport { ContentBlockHeader, ContentBlockStyles } from \"./styles\";\n\nexport interface ContentBlockProps {\n title: string;\n subtitle: string;\n titleAs: \"h1\" | \"h2\" | \"h3\" | \"h4\";\n subtitleAs: \"h2\" | \"h3\" | \"h4\" | \"h5\" | \"p\";\n isLoading?: boolean;\n content?: React.ReactNode;\n headerActions?: React.ReactNode;\n contentProps?: React.ComponentProps<typeof Box>;\n}\n\nconst ContentBlock: React.FC<ContentBlockProps> = ({\n title,\n subtitle,\n titleAs = \"h2\",\n subtitleAs = \"h3\",\n content,\n isLoading,\n headerActions,\n contentProps,\n ...boxProps\n}) => {\n return (\n <ContentBlockStyles as=\"section\" {...boxProps}>\n <ContentBlockHeader>\n <Box>\n <Text.Headline as={titleAs}>{title}</Text.Headline>\n <Text.Byline as={subtitleAs} fontWeight=\"normal\">\n {subtitle}\n </Text.Byline>\n </Box>\n {headerActions && <Box>{headerActions}</Box>}\n </ContentBlockHeader>\n <Box\n p={400}\n {...contentProps}\n borderBottomLeftRadius=\"outer\"\n borderBottomRightRadius=\"outer\"\n >\n {isLoading ? (\n <Box my={400}>\n <Loader delay={false} />\n </Box>\n ) : (\n content\n )}\n </Box>\n </ContentBlockStyles>\n );\n};\n\nexport default ContentBlock;\n","import styled from \"styled-components\";\nimport { Box } from \"@sproutsocial/seeds-react-box\";\n\nexport const ContentBlockStyles = styled.section`\n background: ${({ theme }) => theme.colors.container.background.base};\n border: ${({ theme }) => theme.borderWidths[500]} solid\n ${({ theme }) => theme.colors.container.border.base};\n border-radius: ${({ theme }) => theme.radii.outer};\n`;\n\nexport const ContentBlockHeader = styled(Box)`\n display: flex;\n justify-content: space-between;\n align-items: center;\n border-bottom: ${({ theme }) => theme.borderWidths[500]} solid\n ${({ theme }) => theme.colors.container.border.base};\n color: ${({ theme }) => theme.colors.text.headline};\n padding: ${({ theme }) => theme.space[400]};\n`;\n\nexport const ContentBlockContent = styled(Box)`\n padding: ${({ theme }) => theme.space[400]};\n`;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAAkB;AAClB,IAAAA,0BAAoB;AACpB,8BAAqB;AACrB,gCAAuB;;;ACHvB,+BAAmB;AACnB,6BAAoB;AAEb,IAAM,qBAAqB,yBAAAC,QAAO;AAAA,gBACzB,CAAC,EAAE,MAAM,MAAM,MAAM,OAAO,UAAU,WAAW,IAAI;AAAA,YACzD,CAAC,EAAE,MAAM,MAAM,MAAM,aAAa,GAAG,CAAC;AAAA,MAC5C,CAAC,EAAE,MAAM,MAAM,MAAM,OAAO,UAAU,OAAO,IAAI;AAAA,mBACpC,CAAC,EAAE,MAAM,MAAM,MAAM,MAAM,KAAK;AAAA;AAG5C,IAAM,yBAAqB,yBAAAA,SAAO,0BAAG;AAAA;AAAA;AAAA;AAAA,mBAIzB,CAAC,EAAE,MAAM,MAAM,MAAM,aAAa,GAAG,CAAC;AAAA,MACnD,CAAC,EAAE,MAAM,MAAM,MAAM,OAAO,UAAU,OAAO,IAAI;AAAA,WAC5C,CAAC,EAAE,MAAM,MAAM,MAAM,OAAO,KAAK,QAAQ;AAAA,aACvC,CAAC,EAAE,MAAM,MAAM,MAAM,MAAM,GAAG,CAAC;AAAA;AAGrC,IAAM,0BAAsB,yBAAAA,SAAO,0BAAG;AAAA,aAChC,CAAC,EAAE,MAAM,MAAM,MAAM,MAAM,GAAG,CAAC;AAAA;;;ADUpC;AAdR,IAAM,eAA4C,CAAC;AAAA,EACjD;AAAA,EACA;AAAA,EACA,UAAU;AAAA,EACV,aAAa;AAAA,EACb;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AACJ,SACE,6CAAC,sBAAmB,IAAG,WAAW,GAAG,UACnC;AAAA,iDAAC,sBACC;AAAA,mDAAC,+BACC;AAAA,oDAAC,6BAAK,UAAL,EAAc,IAAI,SAAU,iBAAM;AAAA,QACnC,4CAAC,6BAAK,QAAL,EAAY,IAAI,YAAY,YAAW,UACrC,oBACH;AAAA,SACF;AAAA,MACC,iBAAiB,4CAAC,+BAAK,yBAAc;AAAA,OACxC;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACC,GAAG;AAAA,QACF,GAAG;AAAA,QACJ,wBAAuB;AAAA,QACvB,yBAAwB;AAAA,QAEvB,sBACC,4CAAC,+BAAI,IAAI,KACP,sDAAC,oCAAO,OAAO,OAAO,GACxB,IAEA;AAAA;AAAA,IAEJ;AAAA,KACF;AAEJ;AAEA,IAAO,uBAAQ;;;ADrDf,IAAO,gBAAQ;","names":["import_seeds_react_box","styled"]}
|
package/jest.config.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sproutsocial/seeds-react-content-block",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Seeds React ContentBlock",
|
|
5
|
+
"author": "Sprout Social, Inc.",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"module": "dist/esm/index.js",
|
|
9
|
+
"types": "dist/index.d.ts",
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "tsup --dts",
|
|
12
|
+
"build:debug": "tsup --dts --metafile",
|
|
13
|
+
"dev": "tsup --watch --dts",
|
|
14
|
+
"clean": "rm -rf .turbo dist",
|
|
15
|
+
"clean:modules": "rm -rf node_modules",
|
|
16
|
+
"typecheck": "tsc --noEmit",
|
|
17
|
+
"test": "jest",
|
|
18
|
+
"test:watch": "jest --watch --coverage=false"
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@sproutsocial/seeds-react-box": "^1.1.7",
|
|
22
|
+
"@sproutsocial/seeds-react-button": "^1.3.7",
|
|
23
|
+
"@sproutsocial/seeds-react-icon": "^2.0.2",
|
|
24
|
+
"@sproutsocial/seeds-react-loader": "^1.0.6",
|
|
25
|
+
"@sproutsocial/seeds-react-system-props": "^3.0.2",
|
|
26
|
+
"@sproutsocial/seeds-react-text": "^1.3.2",
|
|
27
|
+
"@sproutsocial/seeds-react-theme": "^3.2.1"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@types/react": "^18.0.0",
|
|
31
|
+
"@types/styled-components": "^5.1.26",
|
|
32
|
+
"@sproutsocial/eslint-config-seeds": "*",
|
|
33
|
+
"react": "^18.0.0",
|
|
34
|
+
"styled-components": "^5.2.3",
|
|
35
|
+
"tsup": "^8.3.4",
|
|
36
|
+
"typescript": "^5.6.2",
|
|
37
|
+
"@sproutsocial/seeds-tsconfig": "*",
|
|
38
|
+
"@sproutsocial/seeds-testing": "*",
|
|
39
|
+
"@sproutsocial/seeds-react-testing-library": "*"
|
|
40
|
+
},
|
|
41
|
+
"peerDependencies": {
|
|
42
|
+
"styled-components": "^5.2.3"
|
|
43
|
+
},
|
|
44
|
+
"engines": {
|
|
45
|
+
"node": ">=18"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import ContentBlock from "./ContentBlock";
|
|
2
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
3
|
+
import { Text } from "@sproutsocial/seeds-react-text";
|
|
4
|
+
import { Button } from "@sproutsocial/seeds-react-button";
|
|
5
|
+
import { Icon } from "@sproutsocial/seeds-react-icon";
|
|
6
|
+
|
|
7
|
+
const meta: Meta<typeof ContentBlock> = {
|
|
8
|
+
title: "Components/ContentBlock",
|
|
9
|
+
component: ContentBlock,
|
|
10
|
+
args: {
|
|
11
|
+
title: "Volume Breakdown - Outbound",
|
|
12
|
+
subtitle: "View a breakdown of your outbound volume.",
|
|
13
|
+
content: (
|
|
14
|
+
<Text.SmallBodyCopy>
|
|
15
|
+
Here is some content inside the content block.
|
|
16
|
+
</Text.SmallBodyCopy>
|
|
17
|
+
),
|
|
18
|
+
isLoading: false,
|
|
19
|
+
headerActions: null,
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export default meta;
|
|
24
|
+
|
|
25
|
+
type Story = StoryObj<typeof ContentBlock>;
|
|
26
|
+
|
|
27
|
+
export const Default: Story = {
|
|
28
|
+
render: (args) => <ContentBlock {...args} />,
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const WithHeaderActions: Story = {
|
|
32
|
+
render: (args) => (
|
|
33
|
+
<ContentBlock
|
|
34
|
+
{...args}
|
|
35
|
+
headerActions={
|
|
36
|
+
<Button size="small">
|
|
37
|
+
<Icon name="face-frown-open-solid" />
|
|
38
|
+
</Button>
|
|
39
|
+
}
|
|
40
|
+
/>
|
|
41
|
+
),
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export const LoadingState: Story = {
|
|
45
|
+
render: (args) => <ContentBlock {...args} isLoading={true} />,
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export const WithContentStyles: Story = {
|
|
49
|
+
render: (args) => (
|
|
50
|
+
<ContentBlock {...args} contentProps={{ p: 0, py: 400, bg: "blue.300" }} />
|
|
51
|
+
),
|
|
52
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Box } from "@sproutsocial/seeds-react-box";
|
|
3
|
+
import { Text } from "@sproutsocial/seeds-react-text";
|
|
4
|
+
import { Loader } from "@sproutsocial/seeds-react-loader";
|
|
5
|
+
import { ContentBlockHeader, ContentBlockStyles } from "./styles";
|
|
6
|
+
|
|
7
|
+
export interface ContentBlockProps {
|
|
8
|
+
title: string;
|
|
9
|
+
subtitle: string;
|
|
10
|
+
titleAs: "h1" | "h2" | "h3" | "h4";
|
|
11
|
+
subtitleAs: "h2" | "h3" | "h4" | "h5" | "p";
|
|
12
|
+
isLoading?: boolean;
|
|
13
|
+
content?: React.ReactNode;
|
|
14
|
+
headerActions?: React.ReactNode;
|
|
15
|
+
contentProps?: React.ComponentProps<typeof Box>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const ContentBlock: React.FC<ContentBlockProps> = ({
|
|
19
|
+
title,
|
|
20
|
+
subtitle,
|
|
21
|
+
titleAs = "h2",
|
|
22
|
+
subtitleAs = "h3",
|
|
23
|
+
content,
|
|
24
|
+
isLoading,
|
|
25
|
+
headerActions,
|
|
26
|
+
contentProps,
|
|
27
|
+
...boxProps
|
|
28
|
+
}) => {
|
|
29
|
+
return (
|
|
30
|
+
<ContentBlockStyles as="section" {...boxProps}>
|
|
31
|
+
<ContentBlockHeader>
|
|
32
|
+
<Box>
|
|
33
|
+
<Text.Headline as={titleAs}>{title}</Text.Headline>
|
|
34
|
+
<Text.Byline as={subtitleAs} fontWeight="normal">
|
|
35
|
+
{subtitle}
|
|
36
|
+
</Text.Byline>
|
|
37
|
+
</Box>
|
|
38
|
+
{headerActions && <Box>{headerActions}</Box>}
|
|
39
|
+
</ContentBlockHeader>
|
|
40
|
+
<Box
|
|
41
|
+
p={400}
|
|
42
|
+
{...contentProps}
|
|
43
|
+
borderBottomLeftRadius="outer"
|
|
44
|
+
borderBottomRightRadius="outer"
|
|
45
|
+
>
|
|
46
|
+
{isLoading ? (
|
|
47
|
+
<Box my={400}>
|
|
48
|
+
<Loader delay={false} />
|
|
49
|
+
</Box>
|
|
50
|
+
) : (
|
|
51
|
+
content
|
|
52
|
+
)}
|
|
53
|
+
</Box>
|
|
54
|
+
</ContentBlockStyles>
|
|
55
|
+
);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export default ContentBlock;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { render, screen } from "@sproutsocial/seeds-react-testing-library";
|
|
2
|
+
import ContentBlock from "../ContentBlock";
|
|
3
|
+
|
|
4
|
+
describe("ContentBlock Features", () => {
|
|
5
|
+
test("renders title and subtitle with correct semantic elements", () => {
|
|
6
|
+
render(
|
|
7
|
+
<ContentBlock
|
|
8
|
+
title="Test Title"
|
|
9
|
+
subtitle="Test Subtitle"
|
|
10
|
+
titleAs="h1"
|
|
11
|
+
subtitleAs="h2"
|
|
12
|
+
/>
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
const titleElement = screen.getByText("Test Title");
|
|
16
|
+
const subtitleElement = screen.getByText("Test Subtitle");
|
|
17
|
+
|
|
18
|
+
expect(titleElement.tagName).toBe("H1");
|
|
19
|
+
expect(subtitleElement.tagName).toBe("H2");
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
test("renders content when not loading", () => {
|
|
23
|
+
render(
|
|
24
|
+
<ContentBlock
|
|
25
|
+
title="Test Title"
|
|
26
|
+
subtitle="Test Subtitle"
|
|
27
|
+
titleAs="h2"
|
|
28
|
+
subtitleAs="h3"
|
|
29
|
+
isLoading={false}
|
|
30
|
+
content={<div>Loaded Content</div>}
|
|
31
|
+
/>
|
|
32
|
+
);
|
|
33
|
+
expect(screen.getByText("Loaded Content")).toBeInTheDocument();
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
test("renders loader when loading", () => {
|
|
37
|
+
render(
|
|
38
|
+
<ContentBlock
|
|
39
|
+
title="Test Title"
|
|
40
|
+
subtitle="Test Subtitle"
|
|
41
|
+
titleAs="h2"
|
|
42
|
+
subtitleAs="h3"
|
|
43
|
+
isLoading={true}
|
|
44
|
+
/>
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
expect(
|
|
48
|
+
screen.getByDataQaLabel({
|
|
49
|
+
loader: "",
|
|
50
|
+
})
|
|
51
|
+
).toBeInTheDocument();
|
|
52
|
+
});
|
|
53
|
+
});
|
package/src/index.ts
ADDED
package/src/styled.d.ts
ADDED
package/src/styles.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
import { Box } from "@sproutsocial/seeds-react-box";
|
|
3
|
+
|
|
4
|
+
export const ContentBlockStyles = styled.section`
|
|
5
|
+
background: ${({ theme }) => theme.colors.container.background.base};
|
|
6
|
+
border: ${({ theme }) => theme.borderWidths[500]} solid
|
|
7
|
+
${({ theme }) => theme.colors.container.border.base};
|
|
8
|
+
border-radius: ${({ theme }) => theme.radii.outer};
|
|
9
|
+
`;
|
|
10
|
+
|
|
11
|
+
export const ContentBlockHeader = styled(Box)`
|
|
12
|
+
display: flex;
|
|
13
|
+
justify-content: space-between;
|
|
14
|
+
align-items: center;
|
|
15
|
+
border-bottom: ${({ theme }) => theme.borderWidths[500]} solid
|
|
16
|
+
${({ theme }) => theme.colors.container.border.base};
|
|
17
|
+
color: ${({ theme }) => theme.colors.text.headline};
|
|
18
|
+
padding: ${({ theme }) => theme.space[400]};
|
|
19
|
+
`;
|
|
20
|
+
|
|
21
|
+
export const ContentBlockContent = styled(Box)`
|
|
22
|
+
padding: ${({ theme }) => theme.space[400]};
|
|
23
|
+
`;
|
package/tsconfig.json
ADDED
package/tsup.config.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { defineConfig } from "tsup";
|
|
2
|
+
|
|
3
|
+
export default defineConfig((options) => ({
|
|
4
|
+
entry: ["src/index.ts"],
|
|
5
|
+
format: ["cjs", "esm"],
|
|
6
|
+
clean: true,
|
|
7
|
+
legacyOutput: true,
|
|
8
|
+
dts: options.dts,
|
|
9
|
+
external: ["react"],
|
|
10
|
+
sourcemap: true,
|
|
11
|
+
metafile: options.metafile,
|
|
12
|
+
}));
|