@meduza/ui-kit-2 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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Shvembldr
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,183 @@
1
+ # TSDX React User Guide
2
+
3
+ Congrats! You just saved yourself hours of work by bootstrapping this project with TSDX. Let’s get you oriented with what’s here and how to use it.
4
+
5
+ > This TSDX setup is meant for developing React components (not apps!) that can be published to NPM. If you’re looking to build an app, you should use `create-react-app`, `razzle`, `nextjs`, `gatsby`, or `react-static`.
6
+
7
+ > If you’re new to TypeScript and React, checkout [this handy cheatsheet](https://github.com/sw-yx/react-typescript-cheatsheet/)
8
+
9
+ ## Commands
10
+
11
+ TSDX scaffolds your new library inside `/src`, and also sets up a [Parcel-based](https://parceljs.org) playground for it inside `/example`.
12
+
13
+ The recommended workflow is to run TSDX in one terminal:
14
+
15
+ ```
16
+ npm start # or yarn start
17
+ ```
18
+
19
+ This builds to `/dist` and runs the project in watch mode so any edits you save inside `src` causes a rebuild to `/dist`.
20
+
21
+ Then run either example playground or storybook:
22
+
23
+ ### Storybook
24
+
25
+ Run inside another terminal:
26
+
27
+ ```
28
+ yarn storybook
29
+ ```
30
+
31
+ This loads the stories from `./stories`.
32
+
33
+ > NOTE: Stories should reference the components as if using the library, similar to the example playground. This means importing from the root project directory. This has been aliased in the tsconfig and the storybook webpack config as a helper.
34
+
35
+ ### Example
36
+
37
+ Then run the example inside another:
38
+
39
+ ```
40
+ cd example
41
+ npm i # or yarn to install dependencies
42
+ npm start # or yarn start
43
+ ```
44
+
45
+ The default example imports and live reloads whatever is in `/dist`, so if you are seeing an out of date component, make sure TSDX is running in watch mode like we recommend above. **No symlinking required**, [we use Parcel's aliasing](https://github.com/palmerhq/tsdx/pull/88/files).
46
+
47
+ To do a one-off build, use `npm run build` or `yarn build`.
48
+
49
+ To run tests, use `npm test` or `yarn test`.
50
+
51
+ ## Configuration
52
+
53
+ Code quality is [set up for you](https://github.com/palmerhq/tsdx/pull/45/files) with `prettier`, `husky`, and `lint-staged`. Adjust the respective fields in `package.json` accordingly.
54
+
55
+ ### Jest
56
+
57
+ Jest tests are set up to run with `npm test` or `yarn test`. This runs the test watcher (Jest) in an interactive mode. By default, runs tests related to files changed since the last commit.
58
+
59
+ #### Setup Files
60
+
61
+ This is the folder structure we set up for you:
62
+
63
+ ```
64
+ /example
65
+ index.html
66
+ index.tsx # test your component here in a demo app
67
+ package.json
68
+ tsconfig.json
69
+ /src
70
+ index.tsx # EDIT THIS
71
+ /test
72
+ blah.test.tsx # EDIT THIS
73
+ .gitignore
74
+ package.json
75
+ README.md # EDIT THIS
76
+ tsconfig.json
77
+ ```
78
+
79
+ #### React Testing Library
80
+
81
+ We do not set up `react-testing-library` for you yet, we welcome contributions and documentation on this.
82
+
83
+ ### Rollup
84
+
85
+ TSDX uses [Rollup v1.x](https://rollupjs.org) as a bundler and generates multiple rollup configs for various module formats and build settings. See [Optimizations](#optimizations) for details.
86
+
87
+ ### TypeScript
88
+
89
+ `tsconfig.json` is set up to interpret `dom` and `esnext` types, as well as `react` for `jsx`. Adjust according to your needs.
90
+
91
+ ## Continuous Integration
92
+
93
+ ### Travis
94
+
95
+ _to be completed_
96
+
97
+ ### Circle
98
+
99
+ _to be completed_
100
+
101
+ ## Optimizations
102
+
103
+ Please see the main `tsdx` [optimizations docs](https://github.com/palmerhq/tsdx#optimizations). In particular, know that you can take advantage of development-only optimizations:
104
+
105
+ ```js
106
+ // ./types/index.d.ts
107
+ declare var __DEV__: boolean;
108
+
109
+ // inside your code...
110
+ if (__DEV__) {
111
+ console.log('foo');
112
+ }
113
+ ```
114
+
115
+ You can also choose to install and use [invariant](https://github.com/palmerhq/tsdx#invariant) and [warning](https://github.com/palmerhq/tsdx#warning) functions.
116
+
117
+ ## Module Formats
118
+
119
+ CJS, ESModules, and UMD module formats are supported.
120
+
121
+ The appropriate paths are configured in `package.json` and `dist/index.js` accordingly. Please report if any issues are found.
122
+
123
+ ## Using the Playground
124
+
125
+ ```
126
+ cd example
127
+ npm i # or yarn to install dependencies
128
+ npm start # or yarn start
129
+ ```
130
+
131
+ The default example imports and live reloads whatever is in `/dist`, so if you are seeing an out of date component, make sure TSDX is running in watch mode like we recommend above. **No symlinking required**!
132
+
133
+ ## Deploying the Playground
134
+
135
+ The Playground is just a simple [Parcel](https://parceljs.org) app, you can deploy it anywhere you would normally deploy that. Here are some guidelines for **manually** deploying with the Netlify CLI (`npm i -g netlify-cli`):
136
+
137
+ ```bash
138
+ cd example # if not already in the example folder
139
+ npm run build # builds to dist
140
+ netlify deploy # deploy the dist folder
141
+ ```
142
+
143
+ Alternatively, if you already have a git repo connected, you can set up continuous deployment with Netlify:
144
+
145
+ ```bash
146
+ netlify init
147
+ # build command: yarn build && cd example && yarn && yarn build
148
+ # directory to deploy: example/dist
149
+ # pick yes for netlify.toml
150
+ ```
151
+
152
+ ## Named Exports
153
+
154
+ Per Palmer Group guidelines, [always use named exports.](https://github.com/palmerhq/typescript#exports) Code split inside your React app instead of your React library.
155
+
156
+ ## Including Styles
157
+
158
+ There are many ways to ship styles, including with CSS-in-JS. TSDX has no opinion on this, configure how you like.
159
+
160
+ For vanilla CSS, you can include it at the root directory and add it to the `files` section in your `package.json`, so that it can be imported separately by your users and run through their bundler's loader.
161
+
162
+ ## Publishing to NPM
163
+
164
+ We recommend using https://github.com/sindresorhus/np.
165
+
166
+ ## Usage with Lerna
167
+
168
+ When creating a new package with TSDX within a project set up with Lerna, you might encounter a `Cannot resolve dependency` error when trying to run the `example` project. To fix that you will need to make changes to the `package.json` file _inside the `example` directory_.
169
+
170
+ The problem is that due to the nature of how dependencies are installed in Lerna projects, the aliases in the example project's `package.json` might not point to the right place, as those dependencies might have been installed in the root of your Lerna project.
171
+
172
+ Change the `alias` to point to where those packages are actually installed. This depends on the directory structure of your Lerna project, so the actual path might be different from the diff below.
173
+
174
+ ```diff
175
+ "alias": {
176
+ - "react": "../node_modules/react",
177
+ - "react-dom": "../node_modules/react-dom"
178
+ + "react": "../../../node_modules/react",
179
+ + "react-dom": "../../../node_modules/react-dom"
180
+ },
181
+ ```
182
+
183
+ An alternative to fixing this problem would be to remove aliases altogether and define the dependencies referenced as aliases as dev dependencies instead. [However, that might cause other problems.](https://github.com/palmerhq/tsdx/issues/64)
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ export declare type ButtonThemes = 'sand' | 'gold' | 'light' | 'gray' | 'ghost' | 'dark' | 'black' | 'red';
3
+ export declare type ButtonStates = 'isLoading' | 'isDefault';
4
+ export declare type ButtonSizes = 'auto' | 'default';
5
+ export declare type ButtonStyleContexts = 'isInToolbar' | 'isInSpoiler' | 'isInDropdown';
6
+ export interface ButtonProps {
7
+ theme?: ButtonThemes;
8
+ size?: ButtonSizes;
9
+ state?: ButtonStates;
10
+ styleContext?: ButtonStyleContexts;
11
+ disabled?: boolean;
12
+ onClick?: () => void;
13
+ children: React.ReactNode;
14
+ }
@@ -0,0 +1,3 @@
1
+ import { FC } from 'react';
2
+ import { ButtonProps } from './Button.types';
3
+ export declare const Button: FC<ButtonProps>;
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ declare const Loader: React.FC;
3
+ export default Loader;
@@ -0,0 +1 @@
1
+ export * from './Button';
package/dist/index.js ADDED
@@ -0,0 +1,8 @@
1
+
2
+ 'use strict'
3
+
4
+ if (process.env.NODE_ENV === 'production') {
5
+ module.exports = require('./ui-kit-2.cjs.production.min.js')
6
+ } else {
7
+ module.exports = require('./ui-kit-2.cjs.development.js')
8
+ }
@@ -0,0 +1,107 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
6
+
7
+ var React = _interopDefault(require('react'));
8
+
9
+ var makeClassName = function makeClassName(list) {
10
+ return list.filter(function (_ref) {
11
+ var active = _ref[1];
12
+ return active;
13
+ }).map(function (_ref2) {
14
+ var className = _ref2[0];
15
+ return className;
16
+ }).join(' ');
17
+ };
18
+
19
+ var Loader = function Loader() {
20
+ return React.createElement("svg", {
21
+ width: "30px",
22
+ height: "30px",
23
+ viewBox: "0 0 30 30",
24
+ xmlns: "http://www.w3.org/2000/svg"
25
+ }, React.createElement("g", null, React.createElement("path", {
26
+ d: "M15 0C6.716 0 0 6.716 0 15c0 8.284 6.716 15 15 15 8.284 0 15-6.716 15-15 0-8.284-6.716-15-15-15zm0 2c7.18 0 13 5.82 13 13s-5.82 13-13 13S2 22.18 2 15 7.82 2 15 2z",
27
+ opacity: "0.3"
28
+ })), React.createElement("g", {
29
+ fillRule: "evenodd"
30
+ }, React.createElement("animateTransform", {
31
+ attributeName: "transform",
32
+ type: "rotate",
33
+ from: "0 15 15",
34
+ to: "360 15 15",
35
+ dur: "1000ms",
36
+ repeatCount: "indefinite"
37
+ }), React.createElement("path", {
38
+ d: "M15 0c8.18 0 14.83 6.547 14.997 14.686L30 15h-2c0-7.077-5.655-12.833-12.693-12.996L15 2V0z"
39
+ })));
40
+ };
41
+
42
+ function styleInject(css, ref) {
43
+ if ( ref === void 0 ) ref = {};
44
+ var insertAt = ref.insertAt;
45
+
46
+ if (!css || typeof document === 'undefined') { return; }
47
+
48
+ var head = document.head || document.getElementsByTagName('head')[0];
49
+ var style = document.createElement('style');
50
+ style.type = 'text/css';
51
+
52
+ if (insertAt === 'top') {
53
+ if (head.firstChild) {
54
+ head.insertBefore(style, head.firstChild);
55
+ } else {
56
+ head.appendChild(style);
57
+ }
58
+ } else {
59
+ head.appendChild(style);
60
+ }
61
+
62
+ if (style.styleSheet) {
63
+ style.styleSheet.cssText = css;
64
+ } else {
65
+ style.appendChild(document.createTextNode(css));
66
+ }
67
+ }
68
+
69
+ var css_248z = "/* Colors */\n/* Fonts */\n/* Gap */\n/* Media */\n/* 512 */\n/* 650 */\n/* 768 */\n/* 1024 */\n/* 1010 */\n/* 1200 */\n/* 511 */\n/* 1023 */\n/* Zindex */\n.Button-module_root__RpsiW {\n display: block;\n\n padding: 0;\n\n color: #fff;\n\n font-family: 'Proxima Nova', 'Arial', 'Helvetica Neue', sans-serif;\n line-height: 1;\n text-align: center;\n\n border-width: 0;\n outline: none;\n\n cursor: pointer;\n\n transition: background-color 0.15s ease-out;\n\n -webkit-appearance: none;\n\n -moz-appearance: none;\n\n appearance: none;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n}\n.Button-module_root__RpsiW::-moz-focus-inner {\n border: 0;\n}\n.Button-module_root__RpsiW[disabled] {\n cursor: default;\n\n opacity: 0.5;\n\n pointer-events: none;\n}\n.Button-module_root__RpsiW > span:first-child {\n margin-right: 4px;\n}\n.Button-module_root__RpsiW > span:last-child {\n margin-left: 4px;\n}\n.Button-module_gold__ZMYg- {\n background: #b88b59;\n}\n.Button-module_gold__ZMYg-.Button-module_isLoading__1g6QO {\n fill: #b88b59;\n}\n.Button-module_gold__ZMYg-:hover {\n background-color: #9e784c\n}\n@media (hover: none) {\n.Button-module_gold__ZMYg-:hover {\n background-color: #b88b59\n}\n }\n.Button-module_gold__ZMYg-:active {\n background-color: #856440;\n}\n.Button-module_gray__3IM54 {\n color: #000;\n\n background-color: #f0f0f0;\n}\n.Button-module_gray__3IM54.Button-module_isLoading__1g6QO {\n fill: #545454;\n}\n.Button-module_gray__3IM54:hover {\n background-color: #ebebeb\n}\n@media (hover: none) {\n.Button-module_gray__3IM54:hover {\n background-color: #ebebeb\n}\n }\n.Button-module_gray__3IM54:active {\n background-color: #e3e3e3;\n}\n.Button-module_sand__2AqVq {\n background: #a18c68;\n}\n.Button-module_sand__2AqVq.Button-module_isLoading__1g6QO {\n fill: #a18c68;\n}\n.Button-module_sand__2AqVq:hover {\n background-color: #8a7654\n}\n@media (hover: none) {\n.Button-module_sand__2AqVq:hover {\n background-color: #a18c68\n}\n }\n.Button-module_sand__2AqVq:active {\n background-color: #7b6743;\n}\n.Button-module_dark__I0uXx {\n color: #adadad;\n\n background-color: #3a3a3a;\n box-shadow: 0 0 3px 0 rgba(0, 0, 0, 0.4);\n}\n.Button-module_dark__I0uXx:hover {\n background-color: #2e2e2e\n}\n@media (hover: none) {\n.Button-module_dark__I0uXx:hover {\n background-color: #3a3a3a\n}\n }\n.Button-module_dark__I0uXx:active {\n background-color: #242424;\n}\n.Button-module_dark__I0uXx.Button-module_isLoading__1g6QO {\n fill: #3a3a3a;\n}\n.Button-module_light__1Y4hG {\n color: #000;\n\n background-color: #fff;\n}\n.Button-module_light__1Y4hG:hover {\n background-color: #ebebeb\n}\n@media (hover: none) {\n.Button-module_light__1Y4hG:hover {\n background-color: #fff\n}\n }\n.Button-module_light__1Y4hG:active {\n background-color: #e3e3e3;\n}\n.Button-module_light__1Y4hG.Button-module_isLoading__1g6QO {\n fill: #fff;\n}\n.Button-module_black__3sG3Y {\n color: #7e7d7b;\n\n background-color: #000;\n}\n.Button-module_black__3sG3Y.Button-module_isLoading__1g6QO {\n fill: #7e7d7b;\n}\n.Button-module_black__3sG3Y:hover {\n background-color: #141414\n}\n@media (hover: none) {\n.Button-module_black__3sG3Y:hover {\n background: #141414\n}\n }\n.Button-module_black__3sG3Y:active {\n background-color: #242424;\n}\n.Button-module_red__3Niou {\n background-color: #f95a5a;\n}\n.Button-module_red__3Niou:hover {\n background-color: #e65353\n}\n@media (hover: none) {\n.Button-module_red__3Niou:hover {\n background: #f95a5a\n}\n }\n.Button-module_red__3Niou:active {\n background-color: #d44d4d;\n}\n.Button-module_red__3Niou.Button-module_isLoading__1g6QO {\n fill: #141414;\n}\n.Button-module_default__28Vo_ {\n width: 100%;\n height: 42px;\n padding: 7px 18px 6px;\n\n font-weight: 600;\n\n font-size: 12px;\n line-height: 22px;\n\n letter-spacing: 1px;\n text-transform: uppercase;\n\n border-radius: 8px\n}\n@media only screen and (min-device-width: 64em) {\n.Button-module_default__28Vo_ {\n font-size: 14px;\n line-height: 16px\n}\n }\n.Button-module_isInSpoiler__2Yl8c svg {\n margin-top: -2px;\n margin-left: 6px;\n}\n.Button-module_ghost__3awCW {\n\n color: inherit;\n font-weight: inherit;\n font-size: inherit;\n\n font-family: inherit;\n letter-spacing: inherit;\n text-transform: none;\n\n background-color: transparent;\n}\n.Button-module_isInDropdown__1ogKL {\n font-family: 'Proxima Nova', 'Arial', 'Helvetica Neue', sans-serif;\n}\n.Button-module_black__3sG3Y[disabled],\n.Button-module_sand__2AqVq[disabled] {\n opacity: 0.3;\n}\n/* LOADING */\n.Button-module_root__RpsiW.Button-module_isLoading__1g6QO {\n\n background-color: transparent;\n box-shadow: none;\n cursor: default;\n\n pointer-events: none;\n}\n.Button-module_loader__2pl6d {\n display: block;\n\n margin-top: -1px;\n}\n";
70
+ var styles = {"root":"Button-module_root__RpsiW","gold":"Button-module_gold__ZMYg-","isLoading":"Button-module_isLoading__1g6QO","gray":"Button-module_gray__3IM54","sand":"Button-module_sand__2AqVq","dark":"Button-module_dark__I0uXx","light":"Button-module_light__1Y4hG","black":"Button-module_black__3sG3Y","red":"Button-module_red__3Niou","default":"Button-module_default__28Vo_","isInSpoiler":"Button-module_isInSpoiler__2Yl8c","ghost":"Button-module_ghost__3awCW","isInDropdown":"Button-module_isInDropdown__1ogKL","loader":"Button-module_loader__2pl6d"};
71
+ styleInject(css_248z);
72
+
73
+ var Button = function Button(_ref) {
74
+ var _ref$theme = _ref.theme,
75
+ theme = _ref$theme === void 0 ? 'gold' : _ref$theme,
76
+ _ref$size = _ref.size,
77
+ size = _ref$size === void 0 ? 'default' : _ref$size,
78
+ _ref$state = _ref.state,
79
+ state = _ref$state === void 0 ? 'default' : _ref$state,
80
+ _ref$styleContext = _ref.styleContext,
81
+ styleContext = _ref$styleContext === void 0 ? 'isInToolbar' : _ref$styleContext,
82
+ _ref$disabled = _ref.disabled,
83
+ disabled = _ref$disabled === void 0 ? false : _ref$disabled,
84
+ onClick = _ref.onClick,
85
+ children = _ref.children;
86
+
87
+ var handleClick = function handleClick() {
88
+ if (disabled || !onClick) {
89
+ return;
90
+ }
91
+
92
+ onClick();
93
+ };
94
+
95
+ return React.createElement("button", {
96
+ "data-testid": "button",
97
+ className: makeClassName([[styles.root, true], [styles[size], !!size], [styles[theme], !!theme], [styles[state], !!state && !!styles[state]], [styles[styleContext], !!styleContext]]),
98
+ disabled: disabled,
99
+ onClick: handleClick,
100
+ type: "button"
101
+ }, state === 'isLoading' ? React.createElement("span", {
102
+ className: styles.loader
103
+ }, React.createElement(Loader, null)) : children);
104
+ };
105
+
106
+ exports.Button = Button;
107
+ //# sourceMappingURL=ui-kit-2.cjs.development.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ui-kit-2.cjs.development.js","sources":["../src/utils/makeClassName.ts","../src/Button/loader.tsx","../node_modules/style-inject/dist/style-inject.es.js","../src/Button/index.tsx"],"sourcesContent":["const makeClassName = (list: Array<[string, boolean]>): string => {\n return list\n .filter(([, active]) => active)\n .map(([className]) => className)\n .join(' ')\n}\n\nexport default makeClassName\n","import React from 'react'\n\nconst Loader: React.FC = () => (\n <svg\n width=\"30px\"\n height=\"30px\"\n viewBox=\"0 0 30 30\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <g>\n <path\n d=\"M15 0C6.716 0 0 6.716 0 15c0 8.284 6.716 15 15 15 8.284 0 15-6.716 15-15 0-8.284-6.716-15-15-15zm0 2c7.18 0 13 5.82 13 13s-5.82 13-13 13S2 22.18 2 15 7.82 2 15 2z\"\n opacity=\"0.3\"\n />\n </g>\n <g fillRule=\"evenodd\">\n <animateTransform\n attributeName=\"transform\"\n type=\"rotate\"\n from=\"0 15 15\"\n to=\"360 15 15\"\n dur=\"1000ms\"\n repeatCount=\"indefinite\"\n />\n <path d=\"M15 0c8.18 0 14.83 6.547 14.997 14.686L30 15h-2c0-7.077-5.655-12.833-12.693-12.996L15 2V0z\" />\n </g>\n </svg>\n)\n\nexport default Loader\n","function styleInject(css, ref) {\n if ( ref === void 0 ) ref = {};\n var insertAt = ref.insertAt;\n\n if (!css || typeof document === 'undefined') { return; }\n\n var head = document.head || document.getElementsByTagName('head')[0];\n var style = document.createElement('style');\n style.type = 'text/css';\n\n if (insertAt === 'top') {\n if (head.firstChild) {\n head.insertBefore(style, head.firstChild);\n } else {\n head.appendChild(style);\n }\n } else {\n head.appendChild(style);\n }\n\n if (style.styleSheet) {\n style.styleSheet.cssText = css;\n } else {\n style.appendChild(document.createTextNode(css));\n }\n}\n\nexport default styleInject;\n","import React, { FC } from 'react'\n\nimport makeClassName from '../utils/makeClassName'\nimport Loader from './loader'\nimport styles from './Button.module.css'\nimport { ButtonProps } from './Button.types'\n\nexport const Button: FC<ButtonProps> = ({\n theme = 'gold',\n size = 'default',\n state = 'default',\n styleContext = 'isInToolbar',\n disabled = false,\n onClick,\n children\n}) => {\n const handleClick = () => {\n if (disabled || !onClick) {\n return\n }\n\n onClick()\n }\n\n return (\n <button\n data-testid=\"button\"\n className={makeClassName([\n [styles.root, true],\n [styles[size], !!size],\n [styles[theme], !!theme],\n [styles[state], !!state && !!styles[state]],\n [styles[styleContext], !!styleContext]\n ])}\n disabled={disabled}\n onClick={handleClick}\n type=\"button\"\n >\n {state === 'isLoading' ? (\n <span className={styles.loader}>\n <Loader />\n </span>\n ) : (\n children\n )}\n </button>\n )\n}\n"],"names":["makeClassName","list","filter","active","map","className","join","Loader","React","width","height","viewBox","xmlns","d","opacity","fillRule","attributeName","type","from","to","dur","repeatCount","Button","theme","size","state","styleContext","disabled","onClick","children","handleClick","styles","root","loader"],"mappings":";;;;;;;;AAAA,IAAMA,aAAa,GAAG,SAAhBA,aAAgB,CAACC,IAAD;AACpB,SAAOA,IAAI,CACRC,MADI,CACG;AAAA,QAAIC,MAAJ;AAAA,WAAgBA,MAAhB;AAAA,GADH,EAEJC,GAFI,CAEA;AAAA,QAAEC,SAAF;AAAA,WAAiBA,SAAjB;AAAA,GAFA,EAGJC,IAHI,CAGC,GAHD,CAAP;AAID,CALD;;ACEA,IAAMC,MAAM,GAAa,SAAnBA,MAAmB;AAAA,SACvBC,mBAAA,MAAA;AACEC,IAAAA,KAAK,EAAC;AACNC,IAAAA,MAAM,EAAC;AACPC,IAAAA,OAAO,EAAC;AACRC,IAAAA,KAAK,EAAC;GAJR,EAMEJ,mBAAA,IAAA,MAAA,EACEA,mBAAA,OAAA;AACEK,IAAAA,CAAC,EAAC;AACFC,IAAAA,OAAO,EAAC;GAFV,CADF,CANF,EAYEN,mBAAA,IAAA;AAAGO,IAAAA,QAAQ,EAAC;GAAZ,EACEP,mBAAA,mBAAA;AACEQ,IAAAA,aAAa,EAAC;AACdC,IAAAA,IAAI,EAAC;AACLC,IAAAA,IAAI,EAAC;AACLC,IAAAA,EAAE,EAAC;AACHC,IAAAA,GAAG,EAAC;AACJC,IAAAA,WAAW,EAAC;GANd,CADF,EASEb,mBAAA,OAAA;AAAMK,IAAAA,CAAC,EAAC;GAAR,CATF,CAZF,CADuB;AAAA,CAAzB;;ACFA,SAAS,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE;AAC/B,EAAE,KAAK,GAAG,KAAK,KAAK,CAAC,GAAG,GAAG,GAAG,EAAE,CAAC;AACjC,EAAE,IAAI,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC;AAC9B;AACA,EAAE,IAAI,CAAC,GAAG,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE,EAAE,OAAO,EAAE;AAC1D;AACA,EAAE,IAAI,IAAI,GAAG,QAAQ,CAAC,IAAI,IAAI,QAAQ,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AACvE,EAAE,IAAI,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;AAC9C,EAAE,KAAK,CAAC,IAAI,GAAG,UAAU,CAAC;AAC1B;AACA,EAAE,IAAI,QAAQ,KAAK,KAAK,EAAE;AAC1B,IAAI,IAAI,IAAI,CAAC,UAAU,EAAE;AACzB,MAAM,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;AAChD,KAAK,MAAM;AACX,MAAM,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;AAC9B,KAAK;AACL,GAAG,MAAM;AACT,IAAI,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;AAC5B,GAAG;AACH;AACA,EAAE,IAAI,KAAK,CAAC,UAAU,EAAE;AACxB,IAAI,KAAK,CAAC,UAAU,CAAC,OAAO,GAAG,GAAG,CAAC;AACnC,GAAG,MAAM;AACT,IAAI,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC;AACpD,GAAG;AACH,CAAC;;;;;;IClBYS,MAAM,GAAoB,SAA1BA,MAA0B;wBACrCC;MAAAA,gCAAQ;uBACRC;MAAAA,8BAAO;wBACPC;MAAAA,gCAAQ;+BACRC;MAAAA,8CAAe;2BACfC;MAAAA,sCAAW;MACXC,eAAAA;MACAC,gBAAAA;;AAEA,MAAMC,WAAW,GAAG,SAAdA,WAAc;AAClB,QAAIH,QAAQ,IAAI,CAACC,OAAjB,EAA0B;AACxB;AACD;;AAEDA,IAAAA,OAAO;AACR,GAND;;AAQA,SACEpB,mBAAA,SAAA;mBACc;AACZH,IAAAA,SAAS,EAAEL,aAAa,CAAC,CACvB,CAAC+B,MAAM,CAACC,IAAR,EAAc,IAAd,CADuB,EAEvB,CAACD,MAAM,CAACP,IAAD,CAAP,EAAe,CAAC,CAACA,IAAjB,CAFuB,EAGvB,CAACO,MAAM,CAACR,KAAD,CAAP,EAAgB,CAAC,CAACA,KAAlB,CAHuB,EAIvB,CAACQ,MAAM,CAACN,KAAD,CAAP,EAAgB,CAAC,CAACA,KAAF,IAAW,CAAC,CAACM,MAAM,CAACN,KAAD,CAAnC,CAJuB,EAKvB,CAACM,MAAM,CAACL,YAAD,CAAP,EAAuB,CAAC,CAACA,YAAzB,CALuB,CAAD;AAOxBC,IAAAA,QAAQ,EAAEA;AACVC,IAAAA,OAAO,EAAEE;AACTb,IAAAA,IAAI,EAAC;GAXP,EAaGQ,KAAK,KAAK,WAAV,GACCjB,mBAAA,OAAA;AAAMH,IAAAA,SAAS,EAAE0B,MAAM,CAACE;GAAxB,EACEzB,mBAAA,CAACD,MAAD,MAAA,CADF,CADD,GAKCsB,QAlBJ,CADF;AAuBD,CAxCM;;;;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var n,o=(n=require("react"))&&"object"==typeof n&&"default"in n?n.default:n,e=function(){return o.createElement("svg",{width:"30px",height:"30px",viewBox:"0 0 30 30",xmlns:"http://www.w3.org/2000/svg"},o.createElement("g",null,o.createElement("path",{d:"M15 0C6.716 0 0 6.716 0 15c0 8.284 6.716 15 15 15 8.284 0 15-6.716 15-15 0-8.284-6.716-15-15-15zm0 2c7.18 0 13 5.82 13 13s-5.82 13-13 13S2 22.18 2 15 7.82 2 15 2z",opacity:"0.3"})),o.createElement("g",{fillRule:"evenodd"},o.createElement("animateTransform",{attributeName:"transform",type:"rotate",from:"0 15 15",to:"360 15 15",dur:"1000ms",repeatCount:"indefinite"}),o.createElement("path",{d:"M15 0c8.18 0 14.83 6.547 14.997 14.686L30 15h-2c0-7.077-5.655-12.833-12.693-12.996L15 2V0z"})))},t={root:"Button-module_root__RpsiW",gold:"Button-module_gold__ZMYg-",isLoading:"Button-module_isLoading__1g6QO",gray:"Button-module_gray__3IM54",sand:"Button-module_sand__2AqVq",dark:"Button-module_dark__I0uXx",light:"Button-module_light__1Y4hG",black:"Button-module_black__3sG3Y",red:"Button-module_red__3Niou",default:"Button-module_default__28Vo_",isInSpoiler:"Button-module_isInSpoiler__2Yl8c",ghost:"Button-module_ghost__3awCW",isInDropdown:"Button-module_isInDropdown__1ogKL",loader:"Button-module_loader__2pl6d"};!function(n,o){void 0===o&&(o={});var e=o.insertAt;if("undefined"!=typeof document){var t=document.head||document.getElementsByTagName("head")[0],d=document.createElement("style");d.type="text/css","top"===e&&t.firstChild?t.insertBefore(d,t.firstChild):t.appendChild(d),d.styleSheet?d.styleSheet.cssText=n:d.appendChild(document.createTextNode(n))}}("/* Colors */\n/* Fonts */\n/* Gap */\n/* Media */\n/* 512 */\n/* 650 */\n/* 768 */\n/* 1024 */\n/* 1010 */\n/* 1200 */\n/* 511 */\n/* 1023 */\n/* Zindex */\n.Button-module_root__RpsiW {\n display: block;\n\n padding: 0;\n\n color: #fff;\n\n font-family: 'Proxima Nova', 'Arial', 'Helvetica Neue', sans-serif;\n line-height: 1;\n text-align: center;\n\n border-width: 0;\n outline: none;\n\n cursor: pointer;\n\n transition: background-color 0.15s ease-out;\n\n -webkit-appearance: none;\n\n -moz-appearance: none;\n\n appearance: none;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n}\n.Button-module_root__RpsiW::-moz-focus-inner {\n border: 0;\n}\n.Button-module_root__RpsiW[disabled] {\n cursor: default;\n\n opacity: 0.5;\n\n pointer-events: none;\n}\n.Button-module_root__RpsiW > span:first-child {\n margin-right: 4px;\n}\n.Button-module_root__RpsiW > span:last-child {\n margin-left: 4px;\n}\n.Button-module_gold__ZMYg- {\n background: #b88b59;\n}\n.Button-module_gold__ZMYg-.Button-module_isLoading__1g6QO {\n fill: #b88b59;\n}\n.Button-module_gold__ZMYg-:hover {\n background-color: #9e784c\n}\n@media (hover: none) {\n.Button-module_gold__ZMYg-:hover {\n background-color: #b88b59\n}\n }\n.Button-module_gold__ZMYg-:active {\n background-color: #856440;\n}\n.Button-module_gray__3IM54 {\n color: #000;\n\n background-color: #f0f0f0;\n}\n.Button-module_gray__3IM54.Button-module_isLoading__1g6QO {\n fill: #545454;\n}\n.Button-module_gray__3IM54:hover {\n background-color: #ebebeb\n}\n@media (hover: none) {\n.Button-module_gray__3IM54:hover {\n background-color: #ebebeb\n}\n }\n.Button-module_gray__3IM54:active {\n background-color: #e3e3e3;\n}\n.Button-module_sand__2AqVq {\n background: #a18c68;\n}\n.Button-module_sand__2AqVq.Button-module_isLoading__1g6QO {\n fill: #a18c68;\n}\n.Button-module_sand__2AqVq:hover {\n background-color: #8a7654\n}\n@media (hover: none) {\n.Button-module_sand__2AqVq:hover {\n background-color: #a18c68\n}\n }\n.Button-module_sand__2AqVq:active {\n background-color: #7b6743;\n}\n.Button-module_dark__I0uXx {\n color: #adadad;\n\n background-color: #3a3a3a;\n box-shadow: 0 0 3px 0 rgba(0, 0, 0, 0.4);\n}\n.Button-module_dark__I0uXx:hover {\n background-color: #2e2e2e\n}\n@media (hover: none) {\n.Button-module_dark__I0uXx:hover {\n background-color: #3a3a3a\n}\n }\n.Button-module_dark__I0uXx:active {\n background-color: #242424;\n}\n.Button-module_dark__I0uXx.Button-module_isLoading__1g6QO {\n fill: #3a3a3a;\n}\n.Button-module_light__1Y4hG {\n color: #000;\n\n background-color: #fff;\n}\n.Button-module_light__1Y4hG:hover {\n background-color: #ebebeb\n}\n@media (hover: none) {\n.Button-module_light__1Y4hG:hover {\n background-color: #fff\n}\n }\n.Button-module_light__1Y4hG:active {\n background-color: #e3e3e3;\n}\n.Button-module_light__1Y4hG.Button-module_isLoading__1g6QO {\n fill: #fff;\n}\n.Button-module_black__3sG3Y {\n color: #7e7d7b;\n\n background-color: #000;\n}\n.Button-module_black__3sG3Y.Button-module_isLoading__1g6QO {\n fill: #7e7d7b;\n}\n.Button-module_black__3sG3Y:hover {\n background-color: #141414\n}\n@media (hover: none) {\n.Button-module_black__3sG3Y:hover {\n background: #141414\n}\n }\n.Button-module_black__3sG3Y:active {\n background-color: #242424;\n}\n.Button-module_red__3Niou {\n background-color: #f95a5a;\n}\n.Button-module_red__3Niou:hover {\n background-color: #e65353\n}\n@media (hover: none) {\n.Button-module_red__3Niou:hover {\n background: #f95a5a\n}\n }\n.Button-module_red__3Niou:active {\n background-color: #d44d4d;\n}\n.Button-module_red__3Niou.Button-module_isLoading__1g6QO {\n fill: #141414;\n}\n.Button-module_default__28Vo_ {\n width: 100%;\n height: 42px;\n padding: 7px 18px 6px;\n\n font-weight: 600;\n\n font-size: 12px;\n line-height: 22px;\n\n letter-spacing: 1px;\n text-transform: uppercase;\n\n border-radius: 8px\n}\n@media only screen and (min-device-width: 64em) {\n.Button-module_default__28Vo_ {\n font-size: 14px;\n line-height: 16px\n}\n }\n.Button-module_isInSpoiler__2Yl8c svg {\n margin-top: -2px;\n margin-left: 6px;\n}\n.Button-module_ghost__3awCW {\n\n color: inherit;\n font-weight: inherit;\n font-size: inherit;\n\n font-family: inherit;\n letter-spacing: inherit;\n text-transform: none;\n\n background-color: transparent;\n}\n.Button-module_isInDropdown__1ogKL {\n font-family: 'Proxima Nova', 'Arial', 'Helvetica Neue', sans-serif;\n}\n.Button-module_black__3sG3Y[disabled],\n.Button-module_sand__2AqVq[disabled] {\n opacity: 0.3;\n}\n/* LOADING */\n.Button-module_root__RpsiW.Button-module_isLoading__1g6QO {\n\n background-color: transparent;\n box-shadow: none;\n cursor: default;\n\n pointer-events: none;\n}\n.Button-module_loader__2pl6d {\n display: block;\n\n margin-top: -1px;\n}\n"),exports.Button=function(n){var d,u=n.theme,l=void 0===u?"gold":u,r=n.size,a=void 0===r?"default":r,_=n.state,i=void 0===_?"default":_,c=n.styleContext,s=void 0===c?"isInToolbar":c,m=n.disabled,g=void 0!==m&&m,b=n.onClick,p=n.children;return o.createElement("button",{"data-testid":"button",className:(d=[[t.root,!0],[t[a],!!a],[t[l],!!l],[t[i],!!i&&!!t[i]],[t[s],!!s]],d.filter((function(n){return n[1]})).map((function(n){return n[0]})).join(" ")),disabled:g,onClick:function(){!g&&b&&b()},type:"button"},"isLoading"===i?o.createElement("span",{className:t.loader},o.createElement(e,null)):p)};
2
+ //# sourceMappingURL=ui-kit-2.cjs.production.min.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ui-kit-2.cjs.production.min.js","sources":["../src/Button/loader.tsx","../node_modules/style-inject/dist/style-inject.es.js","../src/Button/index.tsx","../src/utils/makeClassName.ts"],"sourcesContent":["import React from 'react'\n\nconst Loader: React.FC = () => (\n <svg\n width=\"30px\"\n height=\"30px\"\n viewBox=\"0 0 30 30\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <g>\n <path\n d=\"M15 0C6.716 0 0 6.716 0 15c0 8.284 6.716 15 15 15 8.284 0 15-6.716 15-15 0-8.284-6.716-15-15-15zm0 2c7.18 0 13 5.82 13 13s-5.82 13-13 13S2 22.18 2 15 7.82 2 15 2z\"\n opacity=\"0.3\"\n />\n </g>\n <g fillRule=\"evenodd\">\n <animateTransform\n attributeName=\"transform\"\n type=\"rotate\"\n from=\"0 15 15\"\n to=\"360 15 15\"\n dur=\"1000ms\"\n repeatCount=\"indefinite\"\n />\n <path d=\"M15 0c8.18 0 14.83 6.547 14.997 14.686L30 15h-2c0-7.077-5.655-12.833-12.693-12.996L15 2V0z\" />\n </g>\n </svg>\n)\n\nexport default Loader\n","function styleInject(css, ref) {\n if ( ref === void 0 ) ref = {};\n var insertAt = ref.insertAt;\n\n if (!css || typeof document === 'undefined') { return; }\n\n var head = document.head || document.getElementsByTagName('head')[0];\n var style = document.createElement('style');\n style.type = 'text/css';\n\n if (insertAt === 'top') {\n if (head.firstChild) {\n head.insertBefore(style, head.firstChild);\n } else {\n head.appendChild(style);\n }\n } else {\n head.appendChild(style);\n }\n\n if (style.styleSheet) {\n style.styleSheet.cssText = css;\n } else {\n style.appendChild(document.createTextNode(css));\n }\n}\n\nexport default styleInject;\n","import React, { FC } from 'react'\n\nimport makeClassName from '../utils/makeClassName'\nimport Loader from './loader'\nimport styles from './Button.module.css'\nimport { ButtonProps } from './Button.types'\n\nexport const Button: FC<ButtonProps> = ({\n theme = 'gold',\n size = 'default',\n state = 'default',\n styleContext = 'isInToolbar',\n disabled = false,\n onClick,\n children\n}) => {\n const handleClick = () => {\n if (disabled || !onClick) {\n return\n }\n\n onClick()\n }\n\n return (\n <button\n data-testid=\"button\"\n className={makeClassName([\n [styles.root, true],\n [styles[size], !!size],\n [styles[theme], !!theme],\n [styles[state], !!state && !!styles[state]],\n [styles[styleContext], !!styleContext]\n ])}\n disabled={disabled}\n onClick={handleClick}\n type=\"button\"\n >\n {state === 'isLoading' ? (\n <span className={styles.loader}>\n <Loader />\n </span>\n ) : (\n children\n )}\n </button>\n )\n}\n","const makeClassName = (list: Array<[string, boolean]>): string => {\n return list\n .filter(([, active]) => active)\n .map(([className]) => className)\n .join(' ')\n}\n\nexport default makeClassName\n"],"names":["Loader","React","width","height","viewBox","xmlns","d","opacity","fillRule","attributeName","type","from","to","dur","repeatCount","css","ref","insertAt","document","head","getElementsByTagName","style","createElement","firstChild","insertBefore","appendChild","styleSheet","cssText","createTextNode","list","theme","size","state","styleContext","disabled","onClick","children","className","styles","root","filter","map","join","loader"],"mappings":"gJAEMA,EAAmB,kBACvBC,uBACEC,MAAM,OACNC,OAAO,OACPC,QAAQ,YACRC,MAAM,8BAENJ,yBACEA,wBACEK,EAAE,qKACFC,QAAQ,SAGZN,qBAAGO,SAAS,WACVP,oCACEQ,cAAc,YACdC,KAAK,SACLC,KAAK,UACLC,GAAG,YACHC,IAAI,SACJC,YAAY,eAEdb,wBAAMK,EAAE,2mBCxBd,SAAqBS,EAAKC,QACX,IAARA,IAAiBA,EAAM,IAC5B,IAAIC,EAAWD,EAAIC,SAEnB,GAAgC,oBAAbC,SAAnB,CAEA,IAAIC,EAAOD,SAASC,MAAQD,SAASE,qBAAqB,QAAQ,GAC9DC,EAAQH,SAASI,cAAc,SACnCD,EAAMX,KAAO,WAEI,QAAbO,GACEE,EAAKI,WACPJ,EAAKK,aAAaH,EAAOF,EAAKI,YAKhCJ,EAAKM,YAAYJ,GAGfA,EAAMK,WACRL,EAAMK,WAAWC,QAAUZ,EAE3BM,EAAMI,YAAYP,SAASU,eAAeb,21JChBP,gBCPhBc,MDQrBC,MAAAA,aAAQ,aACRC,KAAAA,aAAO,gBACPC,MAAAA,aAAQ,gBACRC,aAAAA,aAAe,oBACfC,SAAAA,gBACAC,IAAAA,QACAC,IAAAA,gBAWEnC,wCACc,SACZoC,WC3BiBR,ED2BQ,CACvB,CAACS,EAAOC,MAAM,GACd,CAACD,EAAOP,KAASA,GACjB,CAACO,EAAOR,KAAUA,GAClB,CAACQ,EAAON,KAAUA,KAAWM,EAAON,IACpC,CAACM,EAAOL,KAAiBA,IC/BxBJ,EACJW,QAAO,2BACPC,KAAI,2BACJC,KAAK,MD8BJR,SAAUA,EACVC,QAnBgB,YACdD,GAAaC,GAIjBA,KAeEzB,KAAK,UAEM,cAAVsB,EACC/B,wBAAMoC,UAAWC,EAAOK,QACtB1C,gBAACD,SAGHoC"}
@@ -0,0 +1,101 @@
1
+ import React from 'react';
2
+
3
+ var makeClassName = function makeClassName(list) {
4
+ return list.filter(function (_ref) {
5
+ var active = _ref[1];
6
+ return active;
7
+ }).map(function (_ref2) {
8
+ var className = _ref2[0];
9
+ return className;
10
+ }).join(' ');
11
+ };
12
+
13
+ var Loader = function Loader() {
14
+ return React.createElement("svg", {
15
+ width: "30px",
16
+ height: "30px",
17
+ viewBox: "0 0 30 30",
18
+ xmlns: "http://www.w3.org/2000/svg"
19
+ }, React.createElement("g", null, React.createElement("path", {
20
+ d: "M15 0C6.716 0 0 6.716 0 15c0 8.284 6.716 15 15 15 8.284 0 15-6.716 15-15 0-8.284-6.716-15-15-15zm0 2c7.18 0 13 5.82 13 13s-5.82 13-13 13S2 22.18 2 15 7.82 2 15 2z",
21
+ opacity: "0.3"
22
+ })), React.createElement("g", {
23
+ fillRule: "evenodd"
24
+ }, React.createElement("animateTransform", {
25
+ attributeName: "transform",
26
+ type: "rotate",
27
+ from: "0 15 15",
28
+ to: "360 15 15",
29
+ dur: "1000ms",
30
+ repeatCount: "indefinite"
31
+ }), React.createElement("path", {
32
+ d: "M15 0c8.18 0 14.83 6.547 14.997 14.686L30 15h-2c0-7.077-5.655-12.833-12.693-12.996L15 2V0z"
33
+ })));
34
+ };
35
+
36
+ function styleInject(css, ref) {
37
+ if ( ref === void 0 ) ref = {};
38
+ var insertAt = ref.insertAt;
39
+
40
+ if (!css || typeof document === 'undefined') { return; }
41
+
42
+ var head = document.head || document.getElementsByTagName('head')[0];
43
+ var style = document.createElement('style');
44
+ style.type = 'text/css';
45
+
46
+ if (insertAt === 'top') {
47
+ if (head.firstChild) {
48
+ head.insertBefore(style, head.firstChild);
49
+ } else {
50
+ head.appendChild(style);
51
+ }
52
+ } else {
53
+ head.appendChild(style);
54
+ }
55
+
56
+ if (style.styleSheet) {
57
+ style.styleSheet.cssText = css;
58
+ } else {
59
+ style.appendChild(document.createTextNode(css));
60
+ }
61
+ }
62
+
63
+ var css_248z = "/* Colors */\n/* Fonts */\n/* Gap */\n/* Media */\n/* 512 */\n/* 650 */\n/* 768 */\n/* 1024 */\n/* 1010 */\n/* 1200 */\n/* 511 */\n/* 1023 */\n/* Zindex */\n.Button-module_root__RpsiW {\n display: block;\n\n padding: 0;\n\n color: #fff;\n\n font-family: 'Proxima Nova', 'Arial', 'Helvetica Neue', sans-serif;\n line-height: 1;\n text-align: center;\n\n border-width: 0;\n outline: none;\n\n cursor: pointer;\n\n transition: background-color 0.15s ease-out;\n\n -webkit-appearance: none;\n\n -moz-appearance: none;\n\n appearance: none;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n}\n.Button-module_root__RpsiW::-moz-focus-inner {\n border: 0;\n}\n.Button-module_root__RpsiW[disabled] {\n cursor: default;\n\n opacity: 0.5;\n\n pointer-events: none;\n}\n.Button-module_root__RpsiW > span:first-child {\n margin-right: 4px;\n}\n.Button-module_root__RpsiW > span:last-child {\n margin-left: 4px;\n}\n.Button-module_gold__ZMYg- {\n background: #b88b59;\n}\n.Button-module_gold__ZMYg-.Button-module_isLoading__1g6QO {\n fill: #b88b59;\n}\n.Button-module_gold__ZMYg-:hover {\n background-color: #9e784c\n}\n@media (hover: none) {\n.Button-module_gold__ZMYg-:hover {\n background-color: #b88b59\n}\n }\n.Button-module_gold__ZMYg-:active {\n background-color: #856440;\n}\n.Button-module_gray__3IM54 {\n color: #000;\n\n background-color: #f0f0f0;\n}\n.Button-module_gray__3IM54.Button-module_isLoading__1g6QO {\n fill: #545454;\n}\n.Button-module_gray__3IM54:hover {\n background-color: #ebebeb\n}\n@media (hover: none) {\n.Button-module_gray__3IM54:hover {\n background-color: #ebebeb\n}\n }\n.Button-module_gray__3IM54:active {\n background-color: #e3e3e3;\n}\n.Button-module_sand__2AqVq {\n background: #a18c68;\n}\n.Button-module_sand__2AqVq.Button-module_isLoading__1g6QO {\n fill: #a18c68;\n}\n.Button-module_sand__2AqVq:hover {\n background-color: #8a7654\n}\n@media (hover: none) {\n.Button-module_sand__2AqVq:hover {\n background-color: #a18c68\n}\n }\n.Button-module_sand__2AqVq:active {\n background-color: #7b6743;\n}\n.Button-module_dark__I0uXx {\n color: #adadad;\n\n background-color: #3a3a3a;\n box-shadow: 0 0 3px 0 rgba(0, 0, 0, 0.4);\n}\n.Button-module_dark__I0uXx:hover {\n background-color: #2e2e2e\n}\n@media (hover: none) {\n.Button-module_dark__I0uXx:hover {\n background-color: #3a3a3a\n}\n }\n.Button-module_dark__I0uXx:active {\n background-color: #242424;\n}\n.Button-module_dark__I0uXx.Button-module_isLoading__1g6QO {\n fill: #3a3a3a;\n}\n.Button-module_light__1Y4hG {\n color: #000;\n\n background-color: #fff;\n}\n.Button-module_light__1Y4hG:hover {\n background-color: #ebebeb\n}\n@media (hover: none) {\n.Button-module_light__1Y4hG:hover {\n background-color: #fff\n}\n }\n.Button-module_light__1Y4hG:active {\n background-color: #e3e3e3;\n}\n.Button-module_light__1Y4hG.Button-module_isLoading__1g6QO {\n fill: #fff;\n}\n.Button-module_black__3sG3Y {\n color: #7e7d7b;\n\n background-color: #000;\n}\n.Button-module_black__3sG3Y.Button-module_isLoading__1g6QO {\n fill: #7e7d7b;\n}\n.Button-module_black__3sG3Y:hover {\n background-color: #141414\n}\n@media (hover: none) {\n.Button-module_black__3sG3Y:hover {\n background: #141414\n}\n }\n.Button-module_black__3sG3Y:active {\n background-color: #242424;\n}\n.Button-module_red__3Niou {\n background-color: #f95a5a;\n}\n.Button-module_red__3Niou:hover {\n background-color: #e65353\n}\n@media (hover: none) {\n.Button-module_red__3Niou:hover {\n background: #f95a5a\n}\n }\n.Button-module_red__3Niou:active {\n background-color: #d44d4d;\n}\n.Button-module_red__3Niou.Button-module_isLoading__1g6QO {\n fill: #141414;\n}\n.Button-module_default__28Vo_ {\n width: 100%;\n height: 42px;\n padding: 7px 18px 6px;\n\n font-weight: 600;\n\n font-size: 12px;\n line-height: 22px;\n\n letter-spacing: 1px;\n text-transform: uppercase;\n\n border-radius: 8px\n}\n@media only screen and (min-device-width: 64em) {\n.Button-module_default__28Vo_ {\n font-size: 14px;\n line-height: 16px\n}\n }\n.Button-module_isInSpoiler__2Yl8c svg {\n margin-top: -2px;\n margin-left: 6px;\n}\n.Button-module_ghost__3awCW {\n\n color: inherit;\n font-weight: inherit;\n font-size: inherit;\n\n font-family: inherit;\n letter-spacing: inherit;\n text-transform: none;\n\n background-color: transparent;\n}\n.Button-module_isInDropdown__1ogKL {\n font-family: 'Proxima Nova', 'Arial', 'Helvetica Neue', sans-serif;\n}\n.Button-module_black__3sG3Y[disabled],\n.Button-module_sand__2AqVq[disabled] {\n opacity: 0.3;\n}\n/* LOADING */\n.Button-module_root__RpsiW.Button-module_isLoading__1g6QO {\n\n background-color: transparent;\n box-shadow: none;\n cursor: default;\n\n pointer-events: none;\n}\n.Button-module_loader__2pl6d {\n display: block;\n\n margin-top: -1px;\n}\n";
64
+ var styles = {"root":"Button-module_root__RpsiW","gold":"Button-module_gold__ZMYg-","isLoading":"Button-module_isLoading__1g6QO","gray":"Button-module_gray__3IM54","sand":"Button-module_sand__2AqVq","dark":"Button-module_dark__I0uXx","light":"Button-module_light__1Y4hG","black":"Button-module_black__3sG3Y","red":"Button-module_red__3Niou","default":"Button-module_default__28Vo_","isInSpoiler":"Button-module_isInSpoiler__2Yl8c","ghost":"Button-module_ghost__3awCW","isInDropdown":"Button-module_isInDropdown__1ogKL","loader":"Button-module_loader__2pl6d"};
65
+ styleInject(css_248z);
66
+
67
+ var Button = function Button(_ref) {
68
+ var _ref$theme = _ref.theme,
69
+ theme = _ref$theme === void 0 ? 'gold' : _ref$theme,
70
+ _ref$size = _ref.size,
71
+ size = _ref$size === void 0 ? 'default' : _ref$size,
72
+ _ref$state = _ref.state,
73
+ state = _ref$state === void 0 ? 'default' : _ref$state,
74
+ _ref$styleContext = _ref.styleContext,
75
+ styleContext = _ref$styleContext === void 0 ? 'isInToolbar' : _ref$styleContext,
76
+ _ref$disabled = _ref.disabled,
77
+ disabled = _ref$disabled === void 0 ? false : _ref$disabled,
78
+ onClick = _ref.onClick,
79
+ children = _ref.children;
80
+
81
+ var handleClick = function handleClick() {
82
+ if (disabled || !onClick) {
83
+ return;
84
+ }
85
+
86
+ onClick();
87
+ };
88
+
89
+ return React.createElement("button", {
90
+ "data-testid": "button",
91
+ className: makeClassName([[styles.root, true], [styles[size], !!size], [styles[theme], !!theme], [styles[state], !!state && !!styles[state]], [styles[styleContext], !!styleContext]]),
92
+ disabled: disabled,
93
+ onClick: handleClick,
94
+ type: "button"
95
+ }, state === 'isLoading' ? React.createElement("span", {
96
+ className: styles.loader
97
+ }, React.createElement(Loader, null)) : children);
98
+ };
99
+
100
+ export { Button };
101
+ //# sourceMappingURL=ui-kit-2.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ui-kit-2.esm.js","sources":["../src/utils/makeClassName.ts","../src/Button/loader.tsx","../node_modules/style-inject/dist/style-inject.es.js","../src/Button/index.tsx"],"sourcesContent":["const makeClassName = (list: Array<[string, boolean]>): string => {\n return list\n .filter(([, active]) => active)\n .map(([className]) => className)\n .join(' ')\n}\n\nexport default makeClassName\n","import React from 'react'\n\nconst Loader: React.FC = () => (\n <svg\n width=\"30px\"\n height=\"30px\"\n viewBox=\"0 0 30 30\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <g>\n <path\n d=\"M15 0C6.716 0 0 6.716 0 15c0 8.284 6.716 15 15 15 8.284 0 15-6.716 15-15 0-8.284-6.716-15-15-15zm0 2c7.18 0 13 5.82 13 13s-5.82 13-13 13S2 22.18 2 15 7.82 2 15 2z\"\n opacity=\"0.3\"\n />\n </g>\n <g fillRule=\"evenodd\">\n <animateTransform\n attributeName=\"transform\"\n type=\"rotate\"\n from=\"0 15 15\"\n to=\"360 15 15\"\n dur=\"1000ms\"\n repeatCount=\"indefinite\"\n />\n <path d=\"M15 0c8.18 0 14.83 6.547 14.997 14.686L30 15h-2c0-7.077-5.655-12.833-12.693-12.996L15 2V0z\" />\n </g>\n </svg>\n)\n\nexport default Loader\n","function styleInject(css, ref) {\n if ( ref === void 0 ) ref = {};\n var insertAt = ref.insertAt;\n\n if (!css || typeof document === 'undefined') { return; }\n\n var head = document.head || document.getElementsByTagName('head')[0];\n var style = document.createElement('style');\n style.type = 'text/css';\n\n if (insertAt === 'top') {\n if (head.firstChild) {\n head.insertBefore(style, head.firstChild);\n } else {\n head.appendChild(style);\n }\n } else {\n head.appendChild(style);\n }\n\n if (style.styleSheet) {\n style.styleSheet.cssText = css;\n } else {\n style.appendChild(document.createTextNode(css));\n }\n}\n\nexport default styleInject;\n","import React, { FC } from 'react'\n\nimport makeClassName from '../utils/makeClassName'\nimport Loader from './loader'\nimport styles from './Button.module.css'\nimport { ButtonProps } from './Button.types'\n\nexport const Button: FC<ButtonProps> = ({\n theme = 'gold',\n size = 'default',\n state = 'default',\n styleContext = 'isInToolbar',\n disabled = false,\n onClick,\n children\n}) => {\n const handleClick = () => {\n if (disabled || !onClick) {\n return\n }\n\n onClick()\n }\n\n return (\n <button\n data-testid=\"button\"\n className={makeClassName([\n [styles.root, true],\n [styles[size], !!size],\n [styles[theme], !!theme],\n [styles[state], !!state && !!styles[state]],\n [styles[styleContext], !!styleContext]\n ])}\n disabled={disabled}\n onClick={handleClick}\n type=\"button\"\n >\n {state === 'isLoading' ? (\n <span className={styles.loader}>\n <Loader />\n </span>\n ) : (\n children\n )}\n </button>\n )\n}\n"],"names":["makeClassName","list","filter","active","map","className","join","Loader","React","width","height","viewBox","xmlns","d","opacity","fillRule","attributeName","type","from","to","dur","repeatCount","Button","theme","size","state","styleContext","disabled","onClick","children","handleClick","styles","root","loader"],"mappings":"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"}
@@ -0,0 +1,2 @@
1
+ declare const generateGradient: (color: string) => string;
2
+ export default generateGradient;
@@ -0,0 +1,2 @@
1
+ declare const getElementPositionRelativeToViewport: (element: HTMLElement) => number;
2
+ export default getElementPositionRelativeToViewport;
@@ -0,0 +1,2 @@
1
+ declare const makeClassName: (list: Array<[string, boolean]>) => string;
2
+ export default makeClassName;
@@ -0,0 +1,2 @@
1
+ declare const pluralize: (number: number, one: string, two: string, five: string) => string;
2
+ export default pluralize;
@@ -0,0 +1,2 @@
1
+ declare const postMessage: (element: string, action: string) => void;
2
+ export default postMessage;
@@ -0,0 +1,6 @@
1
+ declare type viewportSize = {
2
+ width: number;
3
+ height: number;
4
+ };
5
+ declare const _default: () => viewportSize;
6
+ export default _default;
package/package.json ADDED
@@ -0,0 +1,90 @@
1
+ {
2
+ "name": "@meduza/ui-kit-2",
3
+ "version": "0.0.1",
4
+ "license": "MIT",
5
+ "main": "dist/index.js",
6
+ "typings": "dist/index.d.ts",
7
+ "files": [
8
+ "dist",
9
+ "src"
10
+ ],
11
+ "engines": {
12
+ "node": ">=10"
13
+ },
14
+ "scripts": {
15
+ "start": "tsdx watch",
16
+ "build": "tsdx build",
17
+ "test": "tsdx test --passWithNoTests",
18
+ "lint": "tsdx lint",
19
+ "prepare": "tsdx build",
20
+ "storybook": "start-storybook -p 6006",
21
+ "build-storybook": "build-storybook"
22
+ },
23
+ "peerDependencies": {
24
+ "react": ">=16"
25
+ },
26
+ "lint-staged": {
27
+ "**/*.ts?(x)": [
28
+ "eslint --fix",
29
+ "git add --force"
30
+ ],
31
+ "**/*.css": [
32
+ "stylelint --fix",
33
+ "git add --force"
34
+ ],
35
+ "*.json": [
36
+ "prettier --write",
37
+ "git add --force"
38
+ ]
39
+ },
40
+ "commitlint": {
41
+ "extends": [
42
+ "@commitlint/config-conventional"
43
+ ]
44
+ },
45
+ "husky": {
46
+ "hooks": {
47
+ "pre-commit": "lint-staged",
48
+ "commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
49
+ }
50
+ },
51
+ "author": "Shvembldr",
52
+ "module": "dist/ui-kit40.esm.js",
53
+ "devDependencies": {
54
+ "@babel/core": "^7.10.5",
55
+ "@commitlint/cli": "^9.1.1",
56
+ "@commitlint/config-conventional": "^9.1.1",
57
+ "@storybook/addon-actions": "^5.3.19",
58
+ "@storybook/addon-docs": "^5.3.19",
59
+ "@storybook/addon-info": "^5.3.19",
60
+ "@storybook/addon-links": "^5.3.19",
61
+ "@storybook/addons": "^5.3.19",
62
+ "@storybook/react": "^5.3.19",
63
+ "@testing-library/react": "^10.4.7",
64
+ "@types/react": "^16.9.43",
65
+ "@types/react-dom": "^16.9.8",
66
+ "babel-loader": "^8.1.0",
67
+ "husky": "^4.2.5",
68
+ "lint-staged": "^10.2.11",
69
+ "postcss-import": "^12.0.1",
70
+ "postcss-loader": "^3.0.0",
71
+ "postcss-modules": "^3.2.0",
72
+ "postcss-preset-env": "^6.7.0",
73
+ "precss": "^4.0.0",
74
+ "react": "^16.13.1",
75
+ "react-docgen-typescript-loader": "^3.7.2",
76
+ "react-dom": "^16.13.1",
77
+ "react-is": "^16.13.1",
78
+ "rollup-plugin-postcss": "^3.1.3",
79
+ "stylelint": "^13.6.1",
80
+ "stylelint-config-rational-order": "^0.1.2",
81
+ "stylelint-config-sass-guidelines": "^7.0.0",
82
+ "stylelint-config-standard": "^20.0.0",
83
+ "stylelint-order": "^4.1.0",
84
+ "ts-loader": "^8.0.1",
85
+ "tsdx": "^0.13.2",
86
+ "tslib": "^2.0.0",
87
+ "typescript": "^3.9.6",
88
+ "typescript-plugin-css-modules": "^2.4.0"
89
+ }
90
+ }
@@ -0,0 +1,257 @@
1
+ @import '../vars.css';
2
+
3
+ .root {
4
+ display: block;
5
+
6
+ padding: 0;
7
+
8
+ color: #fff;
9
+
10
+ font-family: $secondaryFont;
11
+ line-height: 1;
12
+ text-align: center;
13
+
14
+ border-width: 0;
15
+ outline: none;
16
+
17
+ cursor: pointer;
18
+
19
+ transition: background-color 0.15s ease-out;
20
+
21
+ appearance: none;
22
+ user-select: none;
23
+ }
24
+
25
+ .root::-moz-focus-inner {
26
+ border: 0;
27
+ }
28
+
29
+ .root[disabled] {
30
+ cursor: default;
31
+
32
+ opacity: 0.5;
33
+
34
+ pointer-events: none;
35
+ }
36
+
37
+ .root > span:first-child {
38
+ margin-right: 4px;
39
+ }
40
+
41
+ .root > span:last-child {
42
+ margin-left: 4px;
43
+ }
44
+
45
+ .gold {
46
+ background: $gold;
47
+ }
48
+
49
+ .gold.isLoading {
50
+ fill: $gold;
51
+ }
52
+
53
+ .gold:hover {
54
+ background-color: $bronze;
55
+
56
+ @media (hover: none) {
57
+ background-color: $gold;
58
+ }
59
+ }
60
+
61
+ .gold:active {
62
+ background-color: #856440;
63
+ }
64
+
65
+ .gray {
66
+ color: #000;
67
+
68
+ background-color: #f0f0f0;
69
+ }
70
+
71
+ .gray.isLoading {
72
+ fill: #545454;
73
+ }
74
+
75
+ .gray:hover {
76
+ background-color: $smoke;
77
+
78
+ @media (hover: none) {
79
+ background-color: $smoke;
80
+ }
81
+ }
82
+
83
+ .gray:active {
84
+ background-color: #e3e3e3;
85
+ }
86
+
87
+ .sand {
88
+ background: $sand;
89
+ }
90
+
91
+ .sand.isLoading {
92
+ fill: $sand;
93
+ }
94
+
95
+ .sand:hover {
96
+ background-color: #8a7654;
97
+
98
+ @media (hover: none) {
99
+ background-color: $sand;
100
+ }
101
+ }
102
+
103
+ .sand:active {
104
+ background-color: #7b6743;
105
+ }
106
+
107
+ .dark {
108
+ color: #adadad;
109
+
110
+ background-color: #3a3a3a;
111
+ box-shadow: 0 0 3px 0 rgba(0, 0, 0, 0.4);
112
+ }
113
+
114
+ .dark:hover {
115
+ background-color: #2e2e2e;
116
+
117
+ @media (hover: none) {
118
+ background-color: #3a3a3a;
119
+ }
120
+ }
121
+
122
+ .dark:active {
123
+ background-color: #242424;
124
+ }
125
+
126
+ .dark.isLoading {
127
+ fill: #3a3a3a;
128
+ }
129
+
130
+ .light {
131
+ color: #000;
132
+
133
+ background-color: #fff;
134
+ }
135
+
136
+ .light:hover {
137
+ background-color: #ebebeb;
138
+
139
+ @media (hover: none) {
140
+ background-color: #fff;
141
+ }
142
+ }
143
+
144
+ .light:active {
145
+ background-color: #e3e3e3;
146
+ }
147
+
148
+ .light.isLoading {
149
+ fill: #fff;
150
+ }
151
+
152
+ .black {
153
+ color: #7e7d7b;
154
+
155
+ background-color: #000;
156
+ }
157
+
158
+ .black.isLoading {
159
+ fill: #7e7d7b;
160
+ }
161
+
162
+ .black:hover {
163
+ background-color: #141414;
164
+
165
+ @media (hover: none) {
166
+ background: #141414;
167
+ }
168
+ }
169
+
170
+ .black:active {
171
+ background-color: #242424;
172
+ }
173
+
174
+ .red {
175
+ background-color: #f95a5a;
176
+ }
177
+
178
+ .red:hover {
179
+ background-color: #e65353;
180
+
181
+ @media (hover: none) {
182
+ background: #f95a5a;
183
+ }
184
+ }
185
+
186
+ .red:active {
187
+ background-color: #d44d4d;
188
+ }
189
+
190
+ .red.isLoading {
191
+ fill: #141414;
192
+ }
193
+
194
+ .default {
195
+ width: 100%;
196
+ height: 42px;
197
+ padding: 7px 18px 6px;
198
+
199
+ font-weight: 600;
200
+
201
+ font-size: 12px;
202
+ line-height: 22px;
203
+
204
+ letter-spacing: 1px;
205
+ text-transform: uppercase;
206
+
207
+ border-radius: 8px;
208
+
209
+ @media $landscapeTablet {
210
+ font-size: 14px;
211
+ line-height: 16px;
212
+ }
213
+ }
214
+
215
+ .isInSpoiler svg {
216
+ margin-top: -2px;
217
+ margin-left: 6px;
218
+ }
219
+
220
+ .ghost {
221
+
222
+ color: inherit;
223
+ font-weight: inherit;
224
+ font-size: inherit;
225
+
226
+ font-family: inherit;
227
+ letter-spacing: inherit;
228
+ text-transform: none;
229
+
230
+ background-color: transparent;
231
+ }
232
+
233
+ .isInDropdown {
234
+ font-family: $secondaryFont;
235
+ }
236
+
237
+ .black[disabled],
238
+ .sand[disabled] {
239
+ opacity: 0.3;
240
+ }
241
+
242
+ /* LOADING */
243
+
244
+ .root.isLoading {
245
+
246
+ background-color: transparent;
247
+ box-shadow: none;
248
+ cursor: default;
249
+
250
+ pointer-events: none;
251
+ }
252
+
253
+ .loader {
254
+ display: block;
255
+
256
+ margin-top: -1px;
257
+ }
@@ -0,0 +1,25 @@
1
+ import React from 'react'
2
+
3
+ export type ButtonThemes =
4
+ | 'sand'
5
+ | 'gold'
6
+ | 'light'
7
+ | 'gray'
8
+ | 'ghost'
9
+ | 'dark'
10
+ | 'black'
11
+ | 'red'
12
+
13
+ export type ButtonStates = 'isLoading' | 'isDefault'
14
+ export type ButtonSizes = 'auto' | 'default'
15
+ export type ButtonStyleContexts = 'isInToolbar' | 'isInSpoiler' | 'isInDropdown'
16
+
17
+ export interface ButtonProps {
18
+ theme?: ButtonThemes
19
+ size?: ButtonSizes
20
+ state?: ButtonStates
21
+ styleContext?: ButtonStyleContexts
22
+ disabled?: boolean
23
+ onClick?: () => void
24
+ children: React.ReactNode
25
+ }
@@ -0,0 +1,48 @@
1
+ import React, { FC } from 'react'
2
+
3
+ import makeClassName from '../utils/makeClassName'
4
+ import Loader from './loader'
5
+ import styles from './Button.module.css'
6
+ import { ButtonProps } from './Button.types'
7
+
8
+ export const Button: FC<ButtonProps> = ({
9
+ theme = 'gold',
10
+ size = 'default',
11
+ state = 'default',
12
+ styleContext = 'isInToolbar',
13
+ disabled = false,
14
+ onClick,
15
+ children
16
+ }) => {
17
+ const handleClick = () => {
18
+ if (disabled || !onClick) {
19
+ return
20
+ }
21
+
22
+ onClick()
23
+ }
24
+
25
+ return (
26
+ <button
27
+ data-testid="button"
28
+ className={makeClassName([
29
+ [styles.root, true],
30
+ [styles[size], !!size],
31
+ [styles[theme], !!theme],
32
+ [styles[state], !!state && !!styles[state]],
33
+ [styles[styleContext], !!styleContext]
34
+ ])}
35
+ disabled={disabled}
36
+ onClick={handleClick}
37
+ type="button"
38
+ >
39
+ {state === 'isLoading' ? (
40
+ <span className={styles.loader}>
41
+ <Loader />
42
+ </span>
43
+ ) : (
44
+ children
45
+ )}
46
+ </button>
47
+ )
48
+ }
@@ -0,0 +1,30 @@
1
+ import React from 'react'
2
+
3
+ const Loader: React.FC = () => (
4
+ <svg
5
+ width="30px"
6
+ height="30px"
7
+ viewBox="0 0 30 30"
8
+ xmlns="http://www.w3.org/2000/svg"
9
+ >
10
+ <g>
11
+ <path
12
+ d="M15 0C6.716 0 0 6.716 0 15c0 8.284 6.716 15 15 15 8.284 0 15-6.716 15-15 0-8.284-6.716-15-15-15zm0 2c7.18 0 13 5.82 13 13s-5.82 13-13 13S2 22.18 2 15 7.82 2 15 2z"
13
+ opacity="0.3"
14
+ />
15
+ </g>
16
+ <g fillRule="evenodd">
17
+ <animateTransform
18
+ attributeName="transform"
19
+ type="rotate"
20
+ from="0 15 15"
21
+ to="360 15 15"
22
+ dur="1000ms"
23
+ repeatCount="indefinite"
24
+ />
25
+ <path d="M15 0c8.18 0 14.83 6.547 14.997 14.686L30 15h-2c0-7.077-5.655-12.833-12.693-12.996L15 2V0z" />
26
+ </g>
27
+ </svg>
28
+ )
29
+
30
+ export default Loader
@@ -0,0 +1,4 @@
1
+ declare module '*.module.css' {
2
+ const classes: { readonly [key: string]: string }
3
+ export default classes
4
+ }
package/src/index.tsx ADDED
@@ -0,0 +1 @@
1
+ export * from './Button'
@@ -0,0 +1,21 @@
1
+ const generateGradient = (color: string): string => {
2
+ const gradientSteps = [
3
+ [0, 7],
4
+ [0.08, 12],
5
+ [0.16, 17],
6
+ [0.22, 21],
7
+ [0.32, 26],
8
+ [0.42, 32],
9
+ [0.52, 38],
10
+ [0.62, 47],
11
+ [0.72, 57],
12
+ [0.82, 65],
13
+ [1, 82]
14
+ ]
15
+
16
+ const gradient = gradientSteps.map(i => `rgba(${color}, ${i[0]}) ${i[1]}%`)
17
+
18
+ return `linear-gradient(-180deg, ${gradient})`
19
+ }
20
+
21
+ export default generateGradient
@@ -0,0 +1,13 @@
1
+ const getElementPositionRelativeToViewport = (element: HTMLElement): number => {
2
+ const viewportHeight = Math.max(
3
+ document.documentElement.clientHeight,
4
+ window.innerHeight || 0
5
+ )
6
+ const rect = element.getBoundingClientRect()
7
+ return Math.min(
8
+ Math.max(Math.round((rect.top * 100) / viewportHeight) - 100, 0),
9
+ 100
10
+ )
11
+ }
12
+
13
+ export default getElementPositionRelativeToViewport
@@ -0,0 +1,8 @@
1
+ const makeClassName = (list: Array<[string, boolean]>): string => {
2
+ return list
3
+ .filter(([, active]) => active)
4
+ .map(([className]) => className)
5
+ .join(' ')
6
+ }
7
+
8
+ export default makeClassName
@@ -0,0 +1,27 @@
1
+ const pluralize = (
2
+ number: number,
3
+ one: string,
4
+ two: string,
5
+ five: string
6
+ ): string => {
7
+ let n = Math.abs(number)
8
+ n %= 100
9
+
10
+ if (n >= 5 && n <= 20) {
11
+ return five
12
+ }
13
+
14
+ n %= 10
15
+
16
+ if (n === 1) {
17
+ return one
18
+ }
19
+
20
+ if (n >= 2 && n <= 4) {
21
+ return two
22
+ }
23
+
24
+ return five
25
+ }
26
+
27
+ export default pluralize
@@ -0,0 +1,16 @@
1
+ const POST_MESSAGE_PREFIX = 'mdzKitMsg'
2
+
3
+ const postMessage = (element: string, action: string): void => {
4
+ const target = window.top
5
+
6
+ const msg = `${POST_MESSAGE_PREFIX}=${JSON.stringify({
7
+ element,
8
+ action
9
+ })}`
10
+
11
+ if (typeof target !== 'undefined') {
12
+ target.postMessage(msg, '*')
13
+ }
14
+ }
15
+
16
+ export default postMessage
@@ -0,0 +1,15 @@
1
+ type viewportSize = {
2
+ width: number
3
+ height: number
4
+ }
5
+
6
+ export default (): viewportSize => ({
7
+ width:
8
+ window.innerWidth ||
9
+ document.documentElement.clientWidth ||
10
+ document.body.clientWidth,
11
+ height:
12
+ window.innerHeight ||
13
+ document.documentElement.clientHeight ||
14
+ document.body.clientHeight
15
+ })
package/src/vars.css ADDED
@@ -0,0 +1,50 @@
1
+ /* Colors */
2
+ $gold: #b88b59;
3
+ $platinum: #f5f5f5;
4
+ $bronze: #9e784c;
5
+ $highlighter: #fff3bc;
6
+ $yellow: #fff9cd;
7
+ $smoke: #ebebeb;
8
+ $silver: #c0c0c0;
9
+ $ash: #b3b3b3;
10
+ $nikel: #757575;
11
+ $jet: #1a1a1a;
12
+ $sand: #a18c68;
13
+
14
+ $fbColor: #304591;
15
+ $vkColor: #527397;
16
+ $twColor: #31adf4;
17
+ $okColor: #eb722e;
18
+ $tgColor: #2ba5e0;
19
+
20
+ /* Fonts */
21
+ $primaryFont: 'PF Regal', 'PF Regal Text Pro', 'Georgia', serif;
22
+ $secondaryFont: 'Proxima Nova', 'Arial', 'Helvetica Neue', sans-serif;
23
+
24
+ /* Gap */
25
+ $gapLarge: 18px;
26
+ $gapMedium: 15px;
27
+ $gapSmall: 12px;
28
+
29
+ /* Media */
30
+ $mobile: only screen and (min-device-width: 32em); /* 512 */
31
+ $contentWidth: only screen and (min-device-width: 40.625em); /* 650 */
32
+ $portraitTablet: only screen and (min-device-width: 48em); /* 768 */
33
+ $landscapeTablet: only screen and (min-device-width: 64em); /* 1024 */
34
+ $desktop: only screen and (min-device-width: 63.125em); /* 1010 */
35
+ $wideDesktop: only screen and (min-device-width: 75em); /* 1200 */
36
+
37
+ $mobileMax: only screen and (max-device-width: 32.1875em); /* 511 */
38
+ $landscapeTabletMax: only screen and (max-device-width: 63.9375em); /* 1023 */
39
+
40
+ /* Zindex */
41
+ $zIndex-1: 100;
42
+ $zIndex-2: 200;
43
+ $zIndex-3: 300;
44
+ $zIndex-4: 400;
45
+ $zIndex-5: 500;
46
+ $zIndex-6: 600;
47
+ $zIndex-7: 700;
48
+ $zIndex-8: 800;
49
+ $zIndex-9: 900;
50
+ $zIndex-10: 1000;