@sellout/ui 0.0.6 → 0.0.8

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.
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export default function makeEventHandler(executeOnEvent?: Function): (eventHandler: Function) => (event: import("react").FormEvent<HTMLInputElement>) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sellout/ui",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "main": "build/index.js",
5
5
  "module": "build/index.es.js",
6
6
  "jsnext:main": "build/index.es.js",
@@ -24,10 +24,7 @@
24
24
  "@fortawesome/pro-regular-svg-icons": "^5.12.1",
25
25
  "@fortawesome/pro-solid-svg-icons": "^5.12.1",
26
26
  "@fortawesome/react-fontawesome": "^0.1.9",
27
- "@sellout/utils": "^0.0.6",
28
- "@storybook/addon-actions": "^5.3.17",
29
- "@storybook/addon-links": "^5.3.17",
30
- "@storybook/react": "^5.2.8",
27
+ "@sellout/utils": "^0.0.8",
31
28
  "@testing-library/jest-dom": "^4.2.4",
32
29
  "@testing-library/react": "^9.4.0",
33
30
  "@testing-library/user-event": "^7.2.1",
@@ -39,23 +36,21 @@
39
36
  "babel-loader": "^8.0.6",
40
37
  "jest": "^24.9.0",
41
38
  "polished": "^3.4.4",
42
- "react": "^16.13.0",
43
39
  "react-animate-height": "^2.0.20",
44
- "react-dom": "^16.13.0",
45
40
  "rollup": "^1.27.13",
46
41
  "rollup-plugin-commonjs": "^10.1.0",
47
42
  "rollup-plugin-node-resolve": "^5.2.0",
48
43
  "rollup-plugin-peer-deps-external": "^2.2.0",
49
44
  "rollup-plugin-typescript2": "^0.25.3",
50
45
  "standard": "^14.3.1",
51
- "styled-components": "^5.0.1",
52
46
  "ts-jest": "^24.2.0",
53
47
  "typescript": "^3.7.5"
54
48
  },
55
- "gitHead": "293473fa4ad310e0ce454b24ba2670109bac0b4c",
49
+ "gitHead": "db838d4527debf14c48fb71bf0f564ec65152dca",
56
50
  "peerDependencies": {
57
- "react": "^16",
58
- "react-dom": "^16"
51
+ "react": "^16.13.0",
52
+ "react-dom": "^16.13.0",
53
+ "styled-components": "^5.0.1"
59
54
  },
60
55
  "jest": {
61
56
  "preset": "ts-jest",
package/rollup.config.js CHANGED
@@ -1,55 +1,20 @@
1
- import typescript from 'rollup-plugin-typescript2'
2
- import commonjs from 'rollup-plugin-commonjs'
3
- import external from 'rollup-plugin-peer-deps-external'
4
- import resolve from 'rollup-plugin-node-resolve'
1
+ import typescript from "rollup-plugin-typescript2";
2
+ import pkg from "./package.json";
5
3
 
6
- import pkg from './package.json'
4
+ console.log(Object.keys(pkg.peerDependencies || {}));
7
5
 
8
- export default {
9
- input: 'src/index.ts',
10
- output: [
11
- {
12
- file: pkg.main,
13
- format: 'cjs',
14
- exports: 'named',
15
- sourcemap: true
16
- },
17
- {
18
- file: pkg.module,
19
- format: 'es',
20
- exports: 'named',
21
- sourcemap: true
22
- }
23
- ],
24
- plugins: [
25
- external(),
26
- resolve(),
27
- typescript({
28
- rollupCommonJSResolveHack: true,
29
- exclude: [
30
- '**/*.stories.js'
31
- ],
32
- clean: true
33
- }),
34
- commonjs({
35
- include: 'node_modules/**',
36
- // left-hand side can be an absolute path, a path
37
- // relative to the current directory, or the name
38
- // of a module in node_modules
39
- namedExports: {
40
- 'node_modules/react/index.js': [
41
- 'cloneElement',
42
- 'createContext',
43
- 'Component',
44
- 'createElement'
45
- ],
46
- 'node_modules/react-dom/index.js': ['render', 'hydrate'],
47
- 'node_modules/react-is/index.js': [
48
- 'isElement',
49
- 'isValidElementType',
50
- 'ForwardRef'
51
- ]
52
- }
53
- }),
54
- ]
55
- }
6
+ export default [
7
+ {
8
+ input: "src/index.ts",
9
+ external: Object.keys(pkg.peerDependencies || {}),
10
+ plugins: [
11
+ typescript({
12
+ typescript: require("typescript")
13
+ })
14
+ ],
15
+ output: [
16
+ { file: pkg.main, format: "cjs" },
17
+ { file: pkg.module, format: "esm" },
18
+ ]
19
+ }
20
+ ];
package/src/Colors.ts CHANGED
@@ -1,7 +1,9 @@
1
1
  export enum Colors {
2
2
  White = "#FFFFFF",
3
- OffWhite = '#FCFCFC',
4
- Blue = '#020151',
3
+ Black = "#000000",
4
+ Green = "#419D78",
5
+ OffWhite = "#FCFCFC",
6
+ Blue = "#020151",
5
7
  Red = "#E63946",
6
8
  Orange = "#FF700F",
7
9
  DarkOrange = "#D65600",
@@ -11,4 +13,5 @@ export enum Colors {
11
13
  Grey4 = "#BDBDBD",
12
14
  Grey5 = "#E0E0E0",
13
15
  Grey6 = "#F2F2F2",
16
+ Grey7 = 'F8F8F8',
14
17
  }
@@ -7,7 +7,7 @@ export const Icons = IconEnum;
7
7
 
8
8
  export type IconProps = {
9
9
  icon: any;
10
- color?: Colors | null;
10
+ color?: Colors | string | null;
11
11
  onClick?: any | null;
12
12
  size?: string | number | undefined;
13
13
  position?: string;
@@ -8,9 +8,11 @@ import Loader, { LoaderSizes } from "./Loader";
8
8
  type FormProps = {
9
9
  hovered: boolean;
10
10
  focused: boolean;
11
+ width?: string;
11
12
  };
12
13
 
13
14
  const Form = styled.form<FormProps>`
15
+ width: ${props => props.width};
14
16
  display: flex;
15
17
  flex-direction: row;
16
18
  position: relative;
@@ -111,11 +113,12 @@ const InputStyled = styled.input<StyledInputProps>`
111
113
  `;
112
114
 
113
115
  export type InputProps = {
116
+ inputRef?: React.Ref<HTMLInputElement>;
114
117
  autoFocus?: boolean | undefined;
115
118
  placeholder?: string;
116
119
  value: string;
117
120
  defaultValue?: string;
118
- icon?: string;
121
+ icon?: any;
119
122
  type?: string;
120
123
  onMouseEnter?: any;
121
124
  onMouseLeave?: any;
@@ -124,13 +127,15 @@ export type InputProps = {
124
127
  onBlur?: any;
125
128
  onSubmit?: Function;
126
129
  onClear?: Function;
127
- canSubmit?: boolean,
130
+ canSubmit?: boolean;
128
131
  loading?: boolean;
129
132
  margin?: string;
130
133
  padding?: string;
134
+ width?: string;
131
135
  };
132
136
 
133
137
  export default function Input({
138
+ inputRef,
134
139
  autoFocus,
135
140
  placeholder,
136
141
  value,
@@ -148,6 +153,7 @@ export default function Input({
148
153
  loading,
149
154
  margin,
150
155
  padding,
156
+ width,
151
157
  }: InputProps) {
152
158
  const [hovered, setHovered] = useState(false);
153
159
  const [focused, setFocused] = useState(false);
@@ -164,6 +170,7 @@ export default function Input({
164
170
  hovered={hovered}
165
171
  focused={focused}
166
172
  onSubmit={event => submit(event)}
173
+ width={width}
167
174
  >
168
175
  {icon && (
169
176
  <LeftContainer>
@@ -175,6 +182,7 @@ export default function Input({
175
182
  </LeftContainer>
176
183
  )}
177
184
  <InputStyled
185
+ ref={inputRef}
178
186
  autoFocus={autoFocus}
179
187
  placeholder={placeholder}
180
188
  value={value}
@@ -4,7 +4,7 @@ import * as Polished from "polished";
4
4
  import AnimateHeight from "react-animate-height";
5
5
  import { Colors } from "../Colors";
6
6
  import Counter, { CounterProps } from './Counter';
7
- // import * as PriceUtil from '@sellout/utils/.dist/price';
7
+ import * as PriceUtil from '@sellout/utils/.dist/price';
8
8
  // import Icon from "./Icon";
9
9
 
10
10
  type RowProps = {
@@ -25,6 +25,7 @@ const Column = styled.div`
25
25
  const Container = styled.div`
26
26
  background-color: ${Colors.White};
27
27
  padding: 15px;
28
+ border-bottom: 1px solid ${Colors.Grey6};
28
29
  `;
29
30
 
30
31
  const Title = styled.div`
@@ -116,7 +117,6 @@ export default function Product({
116
117
  const toggle = () => {
117
118
  setShowEllipsis(!showEllipsis);
118
119
  setShowMore(!showMore)
119
-
120
120
  }
121
121
 
122
122
  return (
@@ -124,7 +124,7 @@ export default function Product({
124
124
  <Row justify="space-between">
125
125
  <Column>
126
126
  <Title>{title}</Title>
127
- <Price>${price}</Price>
127
+ <Price>${PriceUtil.output(price)}</Price>
128
128
  </Column>
129
129
  <Counter
130
130
  value={value}
@@ -134,9 +134,7 @@ export default function Product({
134
134
  onDecrement={onDecrement}
135
135
  />
136
136
  </Row>
137
- <Row>
138
- {subtitle && <Subtitle>{subtitle}</Subtitle>}
139
- </Row>
137
+ <Row>{subtitle && <Subtitle>{subtitle}</Subtitle>}</Row>
140
138
  {(() => {
141
139
  if (!description) return;
142
140
 
package/src/index.ts CHANGED
@@ -1,21 +1,28 @@
1
1
  import { Colors } from "./Colors";
2
- import Button from './components/Button';
2
+ import Button, { ButtonTypes, ButtonStates } from './components/Button';
3
3
  import Counter from "./components/Counter";
4
4
  import Icon from "./components/Icon";
5
5
  import { IconEnum } from "./components/Icons";
6
6
  import Input from "./components/Input";
7
- import Loader from "./components/Loader";
7
+ import Loader, { LoaderSizes } from "./components/Loader";
8
8
  import Product from "./components/Product";
9
+ import makeEventHandler from './utils/makeEventHandler';
9
10
 
10
11
  const Icons = IconEnum;
11
12
 
12
- export {
13
+ export {
14
+ // Components
13
15
  Colors,
14
16
  Button,
17
+ ButtonTypes,
18
+ ButtonStates,
15
19
  Counter,
16
20
  Icon,
17
21
  Icons,
18
22
  Input,
19
23
  Loader,
24
+ LoaderSizes,
20
25
  Product,
21
- };
26
+ // Utils
27
+ makeEventHandler
28
+ };
@@ -0,0 +1,8 @@
1
+ export default function makeEventHandler(executeOnEvent: Function = () => {}) {
2
+ return function (eventHandler: Function) {
3
+ return function(event: React.FormEvent<HTMLInputElement>) {
4
+ executeOnEvent();
5
+ eventHandler(event.currentTarget.value as string);
6
+ };
7
+ }
8
+ }