@purpurds/container 0.0.1
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/dist/LICENSE.txt +31 -0
- package/dist/container.cjs.js +6 -0
- package/dist/container.cjs.js.map +1 -0
- package/dist/container.d.ts +10 -0
- package/dist/container.d.ts.map +1 -0
- package/dist/container.es.js +62 -0
- package/dist/container.es.js.map +1 -0
- package/dist/metadata.js +7 -0
- package/dist/styles.css +1 -0
- package/package.json +60 -0
- package/src/container.module.scss +46 -0
- package/src/container.stories.tsx +58 -0
- package/src/container.test.tsx +15 -0
- package/src/container.tsx +31 -0
- package/src/global.d.ts +4 -0
package/dist/LICENSE.txt
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
Name: classnames
|
|
2
|
+
Version: 2.5.1
|
|
3
|
+
License: MIT
|
|
4
|
+
Private: false
|
|
5
|
+
Description: A simple utility for conditionally joining classNames together
|
|
6
|
+
Repository: git+https://github.com/JedWatson/classnames.git
|
|
7
|
+
Author: Jed Watson
|
|
8
|
+
License Copyright:
|
|
9
|
+
===
|
|
10
|
+
|
|
11
|
+
The MIT License (MIT)
|
|
12
|
+
|
|
13
|
+
Copyright (c) 2018 Jed Watson
|
|
14
|
+
|
|
15
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
16
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
17
|
+
in the Software without restriction, including without limitation the rights
|
|
18
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
19
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
20
|
+
furnished to do so, subject to the following conditions:
|
|
21
|
+
|
|
22
|
+
The above copyright notice and this permission notice shall be included in all
|
|
23
|
+
copies or substantial portions of the Software.
|
|
24
|
+
|
|
25
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
26
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
27
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
28
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
29
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
30
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
31
|
+
SOFTWARE.
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),d=require("react");function _(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var a={exports:{}};/*!
|
|
2
|
+
Copyright (c) 2018 Jed Watson.
|
|
3
|
+
Licensed under the MIT License (MIT), see
|
|
4
|
+
http://jedwatson.github.io/classnames
|
|
5
|
+
*/var c;function m(){return c||(c=1,function(t){(function(){var s={}.hasOwnProperty;function e(){for(var r="",n=0;n<arguments.length;n++){var o=arguments[n];o&&(r=i(r,u.call(this,o)))}return r}function u(r){if(typeof r=="string"||typeof r=="number")return this&&this[r]||r;if(typeof r!="object")return"";if(Array.isArray(r))return e.apply(this,r);if(r.toString!==Object.prototype.toString&&!r.toString.toString().includes("[native code]"))return r.toString();var n="";for(var o in r)s.call(r,o)&&r[o]&&(n=i(n,this&&this[o]||o));return n}function i(r,n){return n?r?r+" "+n:r+n:r}t.exports?(e.default=e,t.exports=e):window.classNames=e})()}(a)),a.exports}var h=m();const y=_(h),b={"purpur-container":"_purpur-container_1nn3a_1","purpur-container--xs":"_purpur-container--xs_1nn3a_12","purpur-container--sm":"_purpur-container--sm_1nn3a_23","purpur-container--md":"_purpur-container--md_1nn3a_38","purpur-container--lg":"_purpur-container--lg_1nn3a_41"},v=y.bind(b),p="purpur-container",f=d.forwardRef(({children:t,className:s,width:e="lg",...u},i)=>{const r=v([s,p,`${p}--${e}`]);return l.jsx("div",{className:r,ref:i,...u,children:t})});f.displayName="Container";exports.Container=f;
|
|
6
|
+
//# sourceMappingURL=container.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"container.cjs.js","sources":["../../../common/temp/node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/bind.js","../src/container.tsx"],"sourcesContent":["/*!\n\tCopyright (c) 2018 Jed Watson.\n\tLicensed under the MIT License (MIT), see\n\thttp://jedwatson.github.io/classnames\n*/\n/* global define */\n\n(function () {\n\t'use strict';\n\n\tvar hasOwn = {}.hasOwnProperty;\n\n\tfunction classNames () {\n\t\tvar classes = '';\n\n\t\tfor (var i = 0; i < arguments.length; i++) {\n\t\t\tvar arg = arguments[i];\n\t\t\tif (arg) {\n\t\t\t\tclasses = appendClass(classes, parseValue.call(this, arg));\n\t\t\t}\n\t\t}\n\n\t\treturn classes;\n\t}\n\n\tfunction parseValue (arg) {\n\t\tif (typeof arg === 'string' || typeof arg === 'number') {\n\t\t\treturn this && this[arg] || arg;\n\t\t}\n\n\t\tif (typeof arg !== 'object') {\n\t\t\treturn '';\n\t\t}\n\n\t\tif (Array.isArray(arg)) {\n\t\t\treturn classNames.apply(this, arg);\n\t\t}\n\n\t\tif (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) {\n\t\t\treturn arg.toString();\n\t\t}\n\n\t\tvar classes = '';\n\n\t\tfor (var key in arg) {\n\t\t\tif (hasOwn.call(arg, key) && arg[key]) {\n\t\t\t\tclasses = appendClass(classes, this && this[key] || key);\n\t\t\t}\n\t\t}\n\n\t\treturn classes;\n\t}\n\n\tfunction appendClass (value, newClass) {\n\t\tif (!newClass) {\n\t\t\treturn value;\n\t\t}\n\t\n\t\tif (value) {\n\t\t\treturn value + ' ' + newClass;\n\t\t}\n\t\n\t\treturn value + newClass;\n\t}\n\n\tif (typeof module !== 'undefined' && module.exports) {\n\t\tclassNames.default = classNames;\n\t\tmodule.exports = classNames;\n\t} else if (typeof define === 'function' && typeof define.amd === 'object' && define.amd) {\n\t\t// register as 'classnames', consistent with npm package name\n\t\tdefine('classnames', [], function () {\n\t\t\treturn classNames;\n\t\t});\n\t} else {\n\t\twindow.classNames = classNames;\n\t}\n}());\n","import React, { ForwardedRef, forwardRef, ReactNode } from \"react\";\nimport c from \"classnames/bind\";\n\nimport styles from \"./container.module.scss\";\nconst cx = c.bind(styles);\n\nexport type ContainerProps = {\n [\"data-testid\"]?: string;\n children: ReactNode;\n className?: string;\n width?: \"xs\" | \"sm\" | \"md\" | \"lg\";\n};\n\nconst rootClassName = \"purpur-container\";\n\nexport const Container = forwardRef(\n (\n { children, className, width = \"lg\", ...props }: ContainerProps,\n ref: ForwardedRef<HTMLDivElement>\n ) => {\n const classes = cx([className, rootClassName, `${rootClassName}--${width}`]);\n\n return (\n <div className={classes} ref={ref} {...props}>\n {children}\n </div>\n );\n }\n);\n\nContainer.displayName = \"Container\";\n"],"names":["hasOwn","classNames","classes","i","arg","appendClass","parseValue","key","value","newClass","module","cx","c","styles","rootClassName","Container","forwardRef","children","className","width","props","ref"],"mappings":";;;;iDAOC,UAAY,CAGZ,IAAIA,EAAS,CAAA,EAAG,eAEhB,SAASC,GAAc,CAGtB,QAFIC,EAAU,GAELC,EAAI,EAAGA,EAAI,UAAU,OAAQA,IAAK,CAC1C,IAAIC,EAAM,UAAUD,CAAC,EACjBC,IACHF,EAAUG,EAAYH,EAASI,EAAW,KAAK,KAAMF,CAAG,CAAC,EAE7D,CAEE,OAAOF,CACT,CAEC,SAASI,EAAYF,EAAK,CACzB,GAAI,OAAOA,GAAQ,UAAY,OAAOA,GAAQ,SAC7C,OAAO,MAAQ,KAAKA,CAAG,GAAKA,EAG7B,GAAI,OAAOA,GAAQ,SAClB,MAAO,GAGR,GAAI,MAAM,QAAQA,CAAG,EACpB,OAAOH,EAAW,MAAM,KAAMG,CAAG,EAGlC,GAAIA,EAAI,WAAa,OAAO,UAAU,UAAY,CAACA,EAAI,SAAS,SAAQ,EAAG,SAAS,eAAe,EAClG,OAAOA,EAAI,SAAU,EAGtB,IAAIF,EAAU,GAEd,QAASK,KAAOH,EACXJ,EAAO,KAAKI,EAAKG,CAAG,GAAKH,EAAIG,CAAG,IACnCL,EAAUG,EAAYH,EAAS,MAAQ,KAAKK,CAAG,GAAKA,CAAG,GAIzD,OAAOL,CACT,CAEC,SAASG,EAAaG,EAAOC,EAAU,CACtC,OAAKA,EAIDD,EACIA,EAAQ,IAAMC,EAGfD,EAAQC,EAPPD,CAQV,CAEsCE,EAAO,SAC3CT,EAAW,QAAUA,EACrBS,UAAiBT,GAOjB,OAAO,WAAaA,CAEtB,8TCxEMU,EAAKC,EAAE,KAAKC,CAAM,EASlBC,EAAgB,mBAETC,EAAYC,EAAA,WACvB,CACE,CAAE,SAAAC,EAAU,UAAAC,EAAW,MAAAC,EAAQ,KAAM,GAAGC,CAAM,EAC9CC,IACG,CACG,MAAAnB,EAAUS,EAAG,CAACO,EAAWJ,EAAe,GAAGA,CAAa,KAAKK,CAAK,EAAE,CAAC,EAE3E,aACG,MAAI,CAAA,UAAWjB,EAAS,IAAAmB,EAAW,GAAGD,EACpC,SAAAH,EACH,CAAA,CAGN,EAEAF,EAAU,YAAc","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { default as React, ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
export type ContainerProps = {
|
|
4
|
+
["data-testid"]?: string;
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
className?: string;
|
|
7
|
+
width?: "xs" | "sm" | "md" | "lg";
|
|
8
|
+
};
|
|
9
|
+
export declare const Container: React.ForwardRefExoticComponent<ContainerProps & React.RefAttributes<HTMLDivElement>>;
|
|
10
|
+
//# sourceMappingURL=container.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../src/container.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAA4B,SAAS,EAAE,MAAM,OAAO,CAAC;AAMnE,MAAM,MAAM,cAAc,GAAG;IAC3B,CAAC,aAAa,CAAC,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,EAAE,SAAS,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;CACnC,CAAC;AAIF,eAAO,MAAM,SAAS,uFAarB,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { jsx as f } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as l } from "react";
|
|
3
|
+
function d(t) {
|
|
4
|
+
return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
|
|
5
|
+
}
|
|
6
|
+
var p = { exports: {} };
|
|
7
|
+
/*!
|
|
8
|
+
Copyright (c) 2018 Jed Watson.
|
|
9
|
+
Licensed under the MIT License (MIT), see
|
|
10
|
+
http://jedwatson.github.io/classnames
|
|
11
|
+
*/
|
|
12
|
+
var a;
|
|
13
|
+
function _() {
|
|
14
|
+
return a || (a = 1, function(t) {
|
|
15
|
+
(function() {
|
|
16
|
+
var s = {}.hasOwnProperty;
|
|
17
|
+
function e() {
|
|
18
|
+
for (var r = "", n = 0; n < arguments.length; n++) {
|
|
19
|
+
var o = arguments[n];
|
|
20
|
+
o && (r = i(r, u.call(this, o)));
|
|
21
|
+
}
|
|
22
|
+
return r;
|
|
23
|
+
}
|
|
24
|
+
function u(r) {
|
|
25
|
+
if (typeof r == "string" || typeof r == "number")
|
|
26
|
+
return this && this[r] || r;
|
|
27
|
+
if (typeof r != "object")
|
|
28
|
+
return "";
|
|
29
|
+
if (Array.isArray(r))
|
|
30
|
+
return e.apply(this, r);
|
|
31
|
+
if (r.toString !== Object.prototype.toString && !r.toString.toString().includes("[native code]"))
|
|
32
|
+
return r.toString();
|
|
33
|
+
var n = "";
|
|
34
|
+
for (var o in r)
|
|
35
|
+
s.call(r, o) && r[o] && (n = i(n, this && this[o] || o));
|
|
36
|
+
return n;
|
|
37
|
+
}
|
|
38
|
+
function i(r, n) {
|
|
39
|
+
return n ? r ? r + " " + n : r + n : r;
|
|
40
|
+
}
|
|
41
|
+
t.exports ? (e.default = e, t.exports = e) : window.classNames = e;
|
|
42
|
+
})();
|
|
43
|
+
}(p)), p.exports;
|
|
44
|
+
}
|
|
45
|
+
var m = _();
|
|
46
|
+
const h = /* @__PURE__ */ d(m), y = {
|
|
47
|
+
"purpur-container": "_purpur-container_1nn3a_1",
|
|
48
|
+
"purpur-container--xs": "_purpur-container--xs_1nn3a_12",
|
|
49
|
+
"purpur-container--sm": "_purpur-container--sm_1nn3a_23",
|
|
50
|
+
"purpur-container--md": "_purpur-container--md_1nn3a_38",
|
|
51
|
+
"purpur-container--lg": "_purpur-container--lg_1nn3a_41"
|
|
52
|
+
}, v = h.bind(y), c = "purpur-container", x = l(
|
|
53
|
+
({ children: t, className: s, width: e = "lg", ...u }, i) => {
|
|
54
|
+
const r = v([s, c, `${c}--${e}`]);
|
|
55
|
+
return /* @__PURE__ */ f("div", { className: r, ref: i, ...u, children: t });
|
|
56
|
+
}
|
|
57
|
+
);
|
|
58
|
+
x.displayName = "Container";
|
|
59
|
+
export {
|
|
60
|
+
x as Container
|
|
61
|
+
};
|
|
62
|
+
//# sourceMappingURL=container.es.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"container.es.js","sources":["../../../common/temp/node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/bind.js","../src/container.tsx"],"sourcesContent":["/*!\n\tCopyright (c) 2018 Jed Watson.\n\tLicensed under the MIT License (MIT), see\n\thttp://jedwatson.github.io/classnames\n*/\n/* global define */\n\n(function () {\n\t'use strict';\n\n\tvar hasOwn = {}.hasOwnProperty;\n\n\tfunction classNames () {\n\t\tvar classes = '';\n\n\t\tfor (var i = 0; i < arguments.length; i++) {\n\t\t\tvar arg = arguments[i];\n\t\t\tif (arg) {\n\t\t\t\tclasses = appendClass(classes, parseValue.call(this, arg));\n\t\t\t}\n\t\t}\n\n\t\treturn classes;\n\t}\n\n\tfunction parseValue (arg) {\n\t\tif (typeof arg === 'string' || typeof arg === 'number') {\n\t\t\treturn this && this[arg] || arg;\n\t\t}\n\n\t\tif (typeof arg !== 'object') {\n\t\t\treturn '';\n\t\t}\n\n\t\tif (Array.isArray(arg)) {\n\t\t\treturn classNames.apply(this, arg);\n\t\t}\n\n\t\tif (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) {\n\t\t\treturn arg.toString();\n\t\t}\n\n\t\tvar classes = '';\n\n\t\tfor (var key in arg) {\n\t\t\tif (hasOwn.call(arg, key) && arg[key]) {\n\t\t\t\tclasses = appendClass(classes, this && this[key] || key);\n\t\t\t}\n\t\t}\n\n\t\treturn classes;\n\t}\n\n\tfunction appendClass (value, newClass) {\n\t\tif (!newClass) {\n\t\t\treturn value;\n\t\t}\n\t\n\t\tif (value) {\n\t\t\treturn value + ' ' + newClass;\n\t\t}\n\t\n\t\treturn value + newClass;\n\t}\n\n\tif (typeof module !== 'undefined' && module.exports) {\n\t\tclassNames.default = classNames;\n\t\tmodule.exports = classNames;\n\t} else if (typeof define === 'function' && typeof define.amd === 'object' && define.amd) {\n\t\t// register as 'classnames', consistent with npm package name\n\t\tdefine('classnames', [], function () {\n\t\t\treturn classNames;\n\t\t});\n\t} else {\n\t\twindow.classNames = classNames;\n\t}\n}());\n","import React, { ForwardedRef, forwardRef, ReactNode } from \"react\";\nimport c from \"classnames/bind\";\n\nimport styles from \"./container.module.scss\";\nconst cx = c.bind(styles);\n\nexport type ContainerProps = {\n [\"data-testid\"]?: string;\n children: ReactNode;\n className?: string;\n width?: \"xs\" | \"sm\" | \"md\" | \"lg\";\n};\n\nconst rootClassName = \"purpur-container\";\n\nexport const Container = forwardRef(\n (\n { children, className, width = \"lg\", ...props }: ContainerProps,\n ref: ForwardedRef<HTMLDivElement>\n ) => {\n const classes = cx([className, rootClassName, `${rootClassName}--${width}`]);\n\n return (\n <div className={classes} ref={ref} {...props}>\n {children}\n </div>\n );\n }\n);\n\nContainer.displayName = \"Container\";\n"],"names":["hasOwn","classNames","classes","i","arg","appendClass","parseValue","key","value","newClass","module","cx","c","styles","rootClassName","Container","forwardRef","children","className","width","props","ref"],"mappings":";;;;;;;;;;;;;;AAOA,KAAC,WAAY;AAGZ,UAAIA,IAAS,CAAA,EAAG;AAEhB,eAASC,IAAc;AAGtB,iBAFIC,IAAU,IAELC,IAAI,GAAGA,IAAI,UAAU,QAAQA,KAAK;AAC1C,cAAIC,IAAM,UAAUD,CAAC;AACrB,UAAIC,MACHF,IAAUG,EAAYH,GAASI,EAAW,KAAK,MAAMF,CAAG,CAAC;AAAA,QAE7D;AAEE,eAAOF;AAAA,MACT;AAEC,eAASI,EAAYF,GAAK;AACzB,YAAI,OAAOA,KAAQ,YAAY,OAAOA,KAAQ;AAC7C,iBAAO,QAAQ,KAAKA,CAAG,KAAKA;AAG7B,YAAI,OAAOA,KAAQ;AAClB,iBAAO;AAGR,YAAI,MAAM,QAAQA,CAAG;AACpB,iBAAOH,EAAW,MAAM,MAAMG,CAAG;AAGlC,YAAIA,EAAI,aAAa,OAAO,UAAU,YAAY,CAACA,EAAI,SAAS,SAAQ,EAAG,SAAS,eAAe;AAClG,iBAAOA,EAAI,SAAU;AAGtB,YAAIF,IAAU;AAEd,iBAASK,KAAOH;AACf,UAAIJ,EAAO,KAAKI,GAAKG,CAAG,KAAKH,EAAIG,CAAG,MACnCL,IAAUG,EAAYH,GAAS,QAAQ,KAAKK,CAAG,KAAKA,CAAG;AAIzD,eAAOL;AAAA,MACT;AAEC,eAASG,EAAaG,GAAOC,GAAU;AACtC,eAAKA,IAIDD,IACIA,IAAQ,MAAMC,IAGfD,IAAQC,IAPPD;AAAA,MAQV;AAEC,MAAqCE,EAAO,WAC3CT,EAAW,UAAUA,GACrBS,YAAiBT,KAOjB,OAAO,aAAaA;AAAA,IAEtB;;;;;;;;;;GCxEMU,IAAKC,EAAE,KAAKC,CAAM,GASlBC,IAAgB,oBAETC,IAAYC;AAAA,EACvB,CACE,EAAE,UAAAC,GAAU,WAAAC,GAAW,OAAAC,IAAQ,MAAM,GAAGC,EAAM,GAC9CC,MACG;AACG,UAAAnB,IAAUS,EAAG,CAACO,GAAWJ,GAAe,GAAGA,CAAa,KAAKK,CAAK,EAAE,CAAC;AAE3E,6BACG,OAAI,EAAA,WAAWjB,GAAS,KAAAmB,GAAW,GAAGD,GACpC,UAAAH,GACH;AAAA,EAAA;AAGN;AAEAF,EAAU,cAAc;","x_google_ignoreList":[0]}
|
package/dist/metadata.js
ADDED
package/dist/styles.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
._purpur-container_1nn3a_1{box-sizing:border-box;width:100%;margin:0 auto;padding:0 var(--padding);--padding: var(--purpur-spacing-page-padding-sm)}@media screen and (min-width: 600px){._purpur-container_1nn3a_1{--padding: var(--purpur-spacing-page-padding-md)}._purpur-container--xs_1nn3a_12{--padding: var(--purpur-spacing-page-padding-sm)}}@media screen and (min-width: 1024px){._purpur-container_1nn3a_1{--padding: var(--purpur-spacing-page-padding-lg)}._purpur-container--xs_1nn3a_12{--padding: var(--purpur-spacing-page-padding-sm)}._purpur-container--sm_1nn3a_23{--padding: var(--purpur-spacing-page-padding-md)}}@media screen and (min-width: 1440px){._purpur-container_1nn3a_1{--padding: var(--purpur-spacing-page-padding-xl)}}._purpur-container--xs_1nn3a_12{max-width:480px}._purpur-container--sm_1nn3a_23{max-width:660px}._purpur-container--md_1nn3a_38{max-width:880px}._purpur-container--lg_1nn3a_41{max-width:var(--purpur-breakpoint-xl)}
|
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@purpurds/container",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"license": "AGPL-3.0-only",
|
|
5
|
+
"main": "./dist/container.cjs.js",
|
|
6
|
+
"types": "./dist/container.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"require": "./dist/container.cjs.js",
|
|
10
|
+
"types": "./dist/container.d.ts",
|
|
11
|
+
"default": "./dist/container.es.js"
|
|
12
|
+
},
|
|
13
|
+
"./styles": "./dist/styles.css",
|
|
14
|
+
"./metadata": "./dist/metadata.js"
|
|
15
|
+
},
|
|
16
|
+
"source": "src/container.tsx",
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"classnames": "~2.5.0",
|
|
19
|
+
"@purpurds/tokens": "6.3.1"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@rushstack/eslint-patch": "~1.10.0",
|
|
23
|
+
"@storybook/blocks": "^8.6.4",
|
|
24
|
+
"@storybook/react": "^8.6.4",
|
|
25
|
+
"@telia/base-rig": "~8.2.0",
|
|
26
|
+
"@telia/react-rig": "~3.2.0",
|
|
27
|
+
"@testing-library/dom": "~10.4.0",
|
|
28
|
+
"@testing-library/jest-dom": "~6.4.0",
|
|
29
|
+
"@testing-library/react": "~16.2.0",
|
|
30
|
+
"@types/node": "20.12.12",
|
|
31
|
+
"@types/react-dom": "^19.0.4",
|
|
32
|
+
"@types/react": "^19.0.10",
|
|
33
|
+
"eslint-plugin-testing-library": "~6.2.0",
|
|
34
|
+
"eslint": "^8.57.0",
|
|
35
|
+
"jsdom": "~22.1.0",
|
|
36
|
+
"lint-staged": "~10.5.3",
|
|
37
|
+
"prettier": "~2.8.8",
|
|
38
|
+
"react-dom": "^19.0.0",
|
|
39
|
+
"react": "^19.0.0",
|
|
40
|
+
"storybook": "^8.6.4",
|
|
41
|
+
"typescript": "^5.6.3",
|
|
42
|
+
"vite": "^6.2.1",
|
|
43
|
+
"vitest": "^2.1.2",
|
|
44
|
+
"@purpurds/component-rig": "1.0.0"
|
|
45
|
+
},
|
|
46
|
+
"scripts": {
|
|
47
|
+
"build:dev": "vite",
|
|
48
|
+
"build:watch": "vite build --watch",
|
|
49
|
+
"build": "vite build",
|
|
50
|
+
"ci:build": "rushx build",
|
|
51
|
+
"coverage": "vitest run --coverage",
|
|
52
|
+
"lint:fix": "eslint . --fix",
|
|
53
|
+
"lint": "lint-staged --no-stash 2>&1",
|
|
54
|
+
"sbdev": "rush sbdev",
|
|
55
|
+
"test:unit": "vitest run --passWithNoTests",
|
|
56
|
+
"test:watch": "vitest --watch",
|
|
57
|
+
"test": "rushx test:unit",
|
|
58
|
+
"typecheck": "tsc -p ./tsconfig.json"
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
@use "@purpurds/tokens/breakpoint/variables" as *;
|
|
2
|
+
|
|
3
|
+
.purpur-container {
|
|
4
|
+
box-sizing: border-box;
|
|
5
|
+
width: 100%;
|
|
6
|
+
margin: 0 auto;
|
|
7
|
+
padding: 0 var(--padding);
|
|
8
|
+
--padding: var(--purpur-spacing-page-padding-sm);
|
|
9
|
+
|
|
10
|
+
@media screen and (min-width: $purpur-breakpoint-md) {
|
|
11
|
+
--padding: var(--purpur-spacing-page-padding-md);
|
|
12
|
+
&--xs {
|
|
13
|
+
--padding: var(--purpur-spacing-page-padding-sm);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
@media screen and (min-width: $purpur-breakpoint-lg) {
|
|
18
|
+
--padding: var(--purpur-spacing-page-padding-lg);
|
|
19
|
+
&--xs {
|
|
20
|
+
--padding: var(--purpur-spacing-page-padding-sm);
|
|
21
|
+
}
|
|
22
|
+
&--sm {
|
|
23
|
+
--padding: var(--purpur-spacing-page-padding-md);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@media screen and (min-width: $purpur-breakpoint-xl) {
|
|
28
|
+
--padding: var(--purpur-spacing-page-padding-xl);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
&--xs {
|
|
32
|
+
max-width: 480px;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
&--sm {
|
|
36
|
+
max-width: 660px;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
&--md {
|
|
40
|
+
max-width: 880px;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
&--lg {
|
|
44
|
+
max-width: var(--purpur-breakpoint-xl);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
3
|
+
|
|
4
|
+
import { Container } from "./container";
|
|
5
|
+
|
|
6
|
+
const meta = {
|
|
7
|
+
title: "Components/Container",
|
|
8
|
+
component: Container,
|
|
9
|
+
parameters: {
|
|
10
|
+
design: [
|
|
11
|
+
{
|
|
12
|
+
name: "Container",
|
|
13
|
+
type: "figma",
|
|
14
|
+
url: "https://www.figma.com/design/2QIcZVqP99ZKY4rNW7VuSx/Purpur-DS---Foundations-library?node-id=5704-10669&p=f&t=9JddBITR86a43RCE-0",
|
|
15
|
+
},
|
|
16
|
+
],
|
|
17
|
+
},
|
|
18
|
+
args: {
|
|
19
|
+
width: "lg",
|
|
20
|
+
},
|
|
21
|
+
} satisfies Meta<typeof Container>;
|
|
22
|
+
|
|
23
|
+
export default meta;
|
|
24
|
+
type Story = StoryObj<typeof Container>;
|
|
25
|
+
|
|
26
|
+
const style = {
|
|
27
|
+
display: "flex",
|
|
28
|
+
justifyContent: "center",
|
|
29
|
+
alignItems: "center",
|
|
30
|
+
backgroundColor: "lavender",
|
|
31
|
+
height: "50vh",
|
|
32
|
+
fontSize: "2rem",
|
|
33
|
+
fontWeight: "bold",
|
|
34
|
+
color: "mediumpurple",
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const Showcase: Story = {
|
|
38
|
+
render: (args) => (
|
|
39
|
+
<div style={{ backgroundColor: "thistle" }}>
|
|
40
|
+
<Container {...args}>
|
|
41
|
+
<div style={style}>Page content</div>
|
|
42
|
+
</Container>
|
|
43
|
+
</div>
|
|
44
|
+
),
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export const SmallWidth: Story = {
|
|
48
|
+
args: {
|
|
49
|
+
width: "sm",
|
|
50
|
+
},
|
|
51
|
+
render: (args) => (
|
|
52
|
+
<div style={{ backgroundColor: "thistle" }}>
|
|
53
|
+
<Container {...args}>
|
|
54
|
+
<div style={style}>Even more page content</div>
|
|
55
|
+
</Container>
|
|
56
|
+
</div>
|
|
57
|
+
),
|
|
58
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import * as matchers from "@testing-library/jest-dom/matchers";
|
|
3
|
+
import { render, screen } from "@testing-library/react";
|
|
4
|
+
import { describe, expect, it } from "vitest";
|
|
5
|
+
|
|
6
|
+
import { Container } from "./container";
|
|
7
|
+
|
|
8
|
+
expect.extend(matchers);
|
|
9
|
+
|
|
10
|
+
describe("Container", () => {
|
|
11
|
+
it("should have tests", () => {
|
|
12
|
+
render(<Container data-testid="unique">Some text content</Container>);
|
|
13
|
+
expect(screen.getByTestId("unique")).toHaveTextContent("Some text content");
|
|
14
|
+
});
|
|
15
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React, { ForwardedRef, forwardRef, ReactNode } from "react";
|
|
2
|
+
import c from "classnames/bind";
|
|
3
|
+
|
|
4
|
+
import styles from "./container.module.scss";
|
|
5
|
+
const cx = c.bind(styles);
|
|
6
|
+
|
|
7
|
+
export type ContainerProps = {
|
|
8
|
+
["data-testid"]?: string;
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
className?: string;
|
|
11
|
+
width?: "xs" | "sm" | "md" | "lg";
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const rootClassName = "purpur-container";
|
|
15
|
+
|
|
16
|
+
export const Container = forwardRef(
|
|
17
|
+
(
|
|
18
|
+
{ children, className, width = "lg", ...props }: ContainerProps,
|
|
19
|
+
ref: ForwardedRef<HTMLDivElement>
|
|
20
|
+
) => {
|
|
21
|
+
const classes = cx([className, rootClassName, `${rootClassName}--${width}`]);
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<div className={classes} ref={ref} {...props}>
|
|
25
|
+
{children}
|
|
26
|
+
</div>
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
Container.displayName = "Container";
|
package/src/global.d.ts
ADDED