@vygruppen/spor-react 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/.turbo/turbo-build.log +15 -0
- package/README.md +55 -0
- package/dist/index.d.ts +51 -0
- package/dist/index.js +96 -0
- package/package.json +32 -0
- package/src/SporProvider.tsx +61 -0
- package/src/index.tsx +7 -0
- package/tsconfig.json +8 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
@vygruppen/spor-react:build: cache hit, replaying output 08c08e23f4839a0f
|
|
2
|
+
@vygruppen/spor-react:build:
|
|
3
|
+
@vygruppen/spor-react:build: > @vygruppen/spor-react@0.0.1 build
|
|
4
|
+
@vygruppen/spor-react:build: > tsup src/index.tsx --dts
|
|
5
|
+
@vygruppen/spor-react:build:
|
|
6
|
+
@vygruppen/spor-react:build: [34mCLI[39m Building entry: src/index.tsx
|
|
7
|
+
@vygruppen/spor-react:build: [34mCLI[39m Using tsconfig: tsconfig.json
|
|
8
|
+
@vygruppen/spor-react:build: [34mCLI[39m tsup v5.11.11
|
|
9
|
+
@vygruppen/spor-react:build: [34mCLI[39m Target: node12
|
|
10
|
+
@vygruppen/spor-react:build: [34mCJS[39m Build start
|
|
11
|
+
@vygruppen/spor-react:build: [32mCJS[39m ⚡️ Build success in 28ms
|
|
12
|
+
@vygruppen/spor-react:build: [32mCJS[39m [1mdist/index.js [22m[32m3.92 KB[39m
|
|
13
|
+
@vygruppen/spor-react:build: [34mDTS[39m Build start
|
|
14
|
+
@vygruppen/spor-react:build: [32mDTS[39m ⚡️ Build success in 4588ms
|
|
15
|
+
@vygruppen/spor-react:build: [32mDTS[39m [1mdist/index.d.ts [22m[32m1.90 KB[39m
|
package/README.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Spor React Component library
|
|
2
|
+
|
|
3
|
+
This package includes everything you need to build your React component library. It's built with TypeScript, but you can use it with JavaScript if you want.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
$ npm install @vygruppen/spor-react
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
Import the components and functions you need as named imports:
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import { Button, Input } from "@vygruppen/spor-react";
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Each component and function comes with extensive documentation that shows up once you use it. Just hover over the component to make it show up in your IDE. There will also be interactive documentation available online sometime in The Future (tm).
|
|
20
|
+
|
|
21
|
+
This package comes with one component of its own though - the `SporProvider`:
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
import { SporProvider } from "@vygruppen/spor-react";
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
The `SporProvider` provides the rest of the Spor components with a theme and a language preference.
|
|
28
|
+
|
|
29
|
+
Wrap your entire app with this component. It's important to place it before you render any UI, like where you mount your React app (`src/index.tsx` in Create React App based apps, and `pages/_app.tsx` in Next.js based apps).
|
|
30
|
+
|
|
31
|
+
You have to specify the current language (and save/retrieve it somehow). Here's a basic example:
|
|
32
|
+
|
|
33
|
+
```tsx
|
|
34
|
+
import { SporProvider, Language } from "@vygruppen/spor-react";
|
|
35
|
+
|
|
36
|
+
const Root = () => {
|
|
37
|
+
return (
|
|
38
|
+
<SporProvider language={Language.NorwegianBokmal}>
|
|
39
|
+
<App />
|
|
40
|
+
</SporProvider>
|
|
41
|
+
);
|
|
42
|
+
};
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
For more details about internationalization, please refer to the `spor-i18n-react` docs.
|
|
46
|
+
|
|
47
|
+
You can also override the theme. Please refer to the `spor-theme-react` docs.
|
|
48
|
+
|
|
49
|
+
## Development
|
|
50
|
+
|
|
51
|
+
Please refer to the root readme for development notes.
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
```
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { ChakraProviderProps } from '@chakra-ui/react';
|
|
2
|
+
export { extendTheme } from '@chakra-ui/react';
|
|
3
|
+
export * from '@vygruppen/spor-button-react';
|
|
4
|
+
import { Language } from '@vygruppen/spor-i18n-react';
|
|
5
|
+
export * from '@vygruppen/spor-i18n-react';
|
|
6
|
+
export * from '@vygruppen/spor-input-react';
|
|
7
|
+
export * from '@vygruppen/spor-logo-react';
|
|
8
|
+
export * from '@vygruppen/spor-theme-react';
|
|
9
|
+
|
|
10
|
+
declare type SporProviderProps = ChakraProviderProps & {
|
|
11
|
+
language: Language;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* This component is used to provide the specified theme of colors and other
|
|
15
|
+
* design tokens to the remainder of the application, as well as the current language.
|
|
16
|
+
*
|
|
17
|
+
* Please place it as close to the root of your application as possible -
|
|
18
|
+
* at least before rendering any UI.
|
|
19
|
+
*
|
|
20
|
+
* You can pass your own theme to this component. If you don't (and most of the time you won't), the default Spor theme will be used.
|
|
21
|
+
*
|
|
22
|
+
* You do, however, need to specify the current language of your application. This is specified to provide any built-in microcopy and labels for any Spor components.
|
|
23
|
+
*
|
|
24
|
+
* ```tsx
|
|
25
|
+
* * import { SporProvider, Language } from "@spor-react";
|
|
26
|
+
* const root = React.createRoot(document.getElementById("root"))
|
|
27
|
+
* root.render(
|
|
28
|
+
* <SporProvider language={Language.NorwegianBokmal}>
|
|
29
|
+
* <App />
|
|
30
|
+
* </SporProvider>
|
|
31
|
+
* );
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* You can pass specific overrides to the theme if you need to. Adding application specific design tokens, for example could be a useful thing to do.
|
|
35
|
+
*
|
|
36
|
+
* ```tsx
|
|
37
|
+
* import { extendTheme, SporProvider } from "@spor-react";
|
|
38
|
+
* const theme = extendTheme({
|
|
39
|
+
* colors: { myApp: { primary: "tomato" } }
|
|
40
|
+
* });
|
|
41
|
+
* const root = React.createRoot(document.getElementById("root"))
|
|
42
|
+
* root.render(
|
|
43
|
+
* <SporProvider language={Language.English} theme={theme}>
|
|
44
|
+
* <App />
|
|
45
|
+
* </SporProvider>
|
|
46
|
+
* );
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
declare const SporProvider: ({ theme, language, children, ...props }: SporProviderProps) => JSX.Element;
|
|
50
|
+
|
|
51
|
+
export { SporProvider };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
9
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
|
+
var __spreadValues = (a, b) => {
|
|
11
|
+
for (var prop in b || (b = {}))
|
|
12
|
+
if (__hasOwnProp.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
if (__getOwnPropSymbols)
|
|
15
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
16
|
+
if (__propIsEnum.call(b, prop))
|
|
17
|
+
__defNormalProp(a, prop, b[prop]);
|
|
18
|
+
}
|
|
19
|
+
return a;
|
|
20
|
+
};
|
|
21
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
22
|
+
var __objRest = (source, exclude) => {
|
|
23
|
+
var target = {};
|
|
24
|
+
for (var prop in source)
|
|
25
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
26
|
+
target[prop] = source[prop];
|
|
27
|
+
if (source != null && __getOwnPropSymbols)
|
|
28
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
29
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
30
|
+
target[prop] = source[prop];
|
|
31
|
+
}
|
|
32
|
+
return target;
|
|
33
|
+
};
|
|
34
|
+
var __export = (target, all) => {
|
|
35
|
+
for (var name in all)
|
|
36
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
37
|
+
};
|
|
38
|
+
var __reExport = (target, module2, copyDefault, desc) => {
|
|
39
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
40
|
+
for (let key of __getOwnPropNames(module2))
|
|
41
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
42
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
43
|
+
}
|
|
44
|
+
return target;
|
|
45
|
+
};
|
|
46
|
+
var __toESM = (module2, isNodeMode) => {
|
|
47
|
+
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
48
|
+
};
|
|
49
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
50
|
+
return (module2, temp) => {
|
|
51
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
52
|
+
};
|
|
53
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
54
|
+
|
|
55
|
+
// src/index.tsx
|
|
56
|
+
var src_exports = {};
|
|
57
|
+
__export(src_exports, {
|
|
58
|
+
SporProvider: () => SporProvider,
|
|
59
|
+
extendTheme: () => import_react4.extendTheme
|
|
60
|
+
});
|
|
61
|
+
var import_react4 = require("@chakra-ui/react");
|
|
62
|
+
__reExport(src_exports, require("@vygruppen/spor-button-react"));
|
|
63
|
+
__reExport(src_exports, require("@vygruppen/spor-i18n-react"));
|
|
64
|
+
__reExport(src_exports, require("@vygruppen/spor-input-react"));
|
|
65
|
+
__reExport(src_exports, require("@vygruppen/spor-logo-react"));
|
|
66
|
+
__reExport(src_exports, require("@vygruppen/spor-theme-react"));
|
|
67
|
+
|
|
68
|
+
// src/SporProvider.tsx
|
|
69
|
+
var import_react = require("@chakra-ui/react");
|
|
70
|
+
var import_react2 = require("@emotion/react");
|
|
71
|
+
var import_spor_i18n_react = require("@vygruppen/spor-i18n-react");
|
|
72
|
+
var import_react3 = __toESM(require("react"));
|
|
73
|
+
var SporProvider = (_a) => {
|
|
74
|
+
var _b = _a, {
|
|
75
|
+
theme = src_exports.theme,
|
|
76
|
+
language,
|
|
77
|
+
children
|
|
78
|
+
} = _b, props = __objRest(_b, [
|
|
79
|
+
"theme",
|
|
80
|
+
"language",
|
|
81
|
+
"children"
|
|
82
|
+
]);
|
|
83
|
+
return /* @__PURE__ */ import_react3.default.createElement(import_spor_i18n_react.LanguageProvider, {
|
|
84
|
+
value: language
|
|
85
|
+
}, /* @__PURE__ */ import_react3.default.createElement(import_react.ChakraProvider, __spreadValues({
|
|
86
|
+
theme
|
|
87
|
+
}, props), /* @__PURE__ */ import_react3.default.createElement(import_react2.Global, {
|
|
88
|
+
styles: src_exports.fontFaces
|
|
89
|
+
}), children));
|
|
90
|
+
};
|
|
91
|
+
module.exports = __toCommonJS(src_exports);
|
|
92
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
93
|
+
0 && (module.exports = {
|
|
94
|
+
SporProvider,
|
|
95
|
+
extendTheme
|
|
96
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vygruppen/spor-react",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"main": "./src/index.tsx",
|
|
5
|
+
"types": "./src/index.tsx",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsup src/index.tsx --dts",
|
|
9
|
+
"dev": "tsup src/index.tsx --watch"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@chakra-ui/react": "^1.7.3",
|
|
13
|
+
"@emotion/react": "^11.7.1",
|
|
14
|
+
"@emotion/styled": "^11.6.0",
|
|
15
|
+
"@leile/lobo-t": "^1.0.5",
|
|
16
|
+
"@vygruppen/spor-button-react": "*",
|
|
17
|
+
"@vygruppen/spor-input-react": "*",
|
|
18
|
+
"@vygruppen/spor-logo-react": "*",
|
|
19
|
+
"@vygruppen/spor-theme-react": "*",
|
|
20
|
+
"@vygruppen/spor-i18n-react": "*",
|
|
21
|
+
"framer-motion": "^4.1.17"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"react": "^17.0.2",
|
|
25
|
+
"react-dom": "^17.0.2",
|
|
26
|
+
"tsup": "^5.11.11"
|
|
27
|
+
},
|
|
28
|
+
"peerDependencies": {
|
|
29
|
+
"react": ">= 17.0.0",
|
|
30
|
+
"react-dom": ">= 17.0.0"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { ChakraProvider, ChakraProviderProps } from "@chakra-ui/react";
|
|
2
|
+
import { Global } from "@emotion/react";
|
|
3
|
+
import { Language, LanguageProvider } from "@vygruppen/spor-i18n-react";
|
|
4
|
+
import { fontFaces, theme as defaultSporTheme } from "@vygruppen/spor-react";
|
|
5
|
+
import React from "react";
|
|
6
|
+
|
|
7
|
+
type SporProviderProps = ChakraProviderProps & {
|
|
8
|
+
language: Language;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* This component is used to provide the specified theme of colors and other
|
|
13
|
+
* design tokens to the remainder of the application, as well as the current language.
|
|
14
|
+
*
|
|
15
|
+
* Please place it as close to the root of your application as possible -
|
|
16
|
+
* at least before rendering any UI.
|
|
17
|
+
*
|
|
18
|
+
* You can pass your own theme to this component. If you don't (and most of the time you won't), the default Spor theme will be used.
|
|
19
|
+
*
|
|
20
|
+
* You do, however, need to specify the current language of your application. This is specified to provide any built-in microcopy and labels for any Spor components.
|
|
21
|
+
*
|
|
22
|
+
* ```tsx
|
|
23
|
+
* * import { SporProvider, Language } from "@spor-react";
|
|
24
|
+
* const root = React.createRoot(document.getElementById("root"))
|
|
25
|
+
* root.render(
|
|
26
|
+
* <SporProvider language={Language.NorwegianBokmal}>
|
|
27
|
+
* <App />
|
|
28
|
+
* </SporProvider>
|
|
29
|
+
* );
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* You can pass specific overrides to the theme if you need to. Adding application specific design tokens, for example could be a useful thing to do.
|
|
33
|
+
*
|
|
34
|
+
* ```tsx
|
|
35
|
+
* import { extendTheme, SporProvider } from "@spor-react";
|
|
36
|
+
* const theme = extendTheme({
|
|
37
|
+
* colors: { myApp: { primary: "tomato" } }
|
|
38
|
+
* });
|
|
39
|
+
* const root = React.createRoot(document.getElementById("root"))
|
|
40
|
+
* root.render(
|
|
41
|
+
* <SporProvider language={Language.English} theme={theme}>
|
|
42
|
+
* <App />
|
|
43
|
+
* </SporProvider>
|
|
44
|
+
* );
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export const SporProvider = ({
|
|
48
|
+
theme = defaultSporTheme,
|
|
49
|
+
language,
|
|
50
|
+
children,
|
|
51
|
+
...props
|
|
52
|
+
}: SporProviderProps) => {
|
|
53
|
+
return (
|
|
54
|
+
<LanguageProvider value={language}>
|
|
55
|
+
<ChakraProvider theme={theme} {...props}>
|
|
56
|
+
<Global styles={fontFaces} />
|
|
57
|
+
{children}
|
|
58
|
+
</ChakraProvider>
|
|
59
|
+
</LanguageProvider>
|
|
60
|
+
);
|
|
61
|
+
};
|
package/src/index.tsx
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { extendTheme } from "@chakra-ui/react";
|
|
2
|
+
export * from "@vygruppen/spor-button-react";
|
|
3
|
+
export * from "@vygruppen/spor-i18n-react";
|
|
4
|
+
export * from "@vygruppen/spor-input-react";
|
|
5
|
+
export * from "@vygruppen/spor-logo-react";
|
|
6
|
+
export * from "@vygruppen/spor-theme-react";
|
|
7
|
+
export * from "./SporProvider";
|