app-studio 0.0.2 → 0.0.3

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/README.md CHANGED
@@ -64,12 +64,15 @@ const Root = () => {
64
64
 
65
65
  ```jsx
66
66
  import React from 'react';
67
- import { View, useResponsive } from 'app-studio';
67
+ import { View } from 'app-studio';
68
68
 
69
69
  function Example() {
70
- const {screen} = useResponsive()
71
70
  return (
72
- <View backgroundColor="grey" padding={ screen == 'xs' ? 10 : 20}>
71
+ <View
72
+ backgroundColor="grey"
73
+ padding={20}
74
+ on={{ hover: { backgroundColor: 'blue.100' } }}
75
+ >
73
76
  Hello
74
77
  </View>
75
78
  );
@@ -105,7 +108,9 @@ const Example = () => {
105
108
  };
106
109
 
107
110
  return (
108
- <View size={100} {...responsive[screen]}>
111
+ <View size={100}
112
+ {...responsive[screen]}
113
+ >
109
114
  {screen} - mobile : {on('mobile') ? 'yes' : 'no'}
110
115
  </View>
111
116
  );
@@ -142,13 +147,34 @@ import React from 'react';
142
147
  import { ThemeProvider, View } from 'app-studio';
143
148
 
144
149
  const theme = {
145
- fontFamily: 'arial',
150
+
151
+ colors: {
152
+ orange: '#fff7ed',
153
+ cyan:'#ecfeff',
154
+ },
155
+ palette:{
156
+ blueGray: {
157
+ 50: '#f8fafc',
158
+ 100: '#f1f5f9',
159
+ 200: '#e2e8f0',
160
+ 300: '#cbd5e1',
161
+ 400: '#94a3b8',
162
+ 500: '#64748b',
163
+ 600: '#475569',
164
+ 700: '#334155',
165
+ 800: '#1e293b',
166
+ 900: '#0f172a',
167
+ },
168
+ }
169
+
146
170
  };
147
171
 
148
172
  function Example() {
149
173
  return (
150
174
  <ThemeProvider theme={theme}>
151
- <View>Hello</View>
175
+ <View backgroundColor="cyan">
176
+ <Text color="blue.200">Hello</Text>
177
+ </View>
152
178
  </ThemeProvider>
153
179
  );
154
180
  }
@@ -197,7 +223,11 @@ If you are a collaborator, please follow our [Pull Request principle](https://gi
197
223
  | title | string | undefined | change the title |
198
224
  | description | string | undefined | change the descrition | -->
199
225
 
226
+ ## Roadmap
200
227
 
228
+ - Integrate React Native
229
+ - Build a documentation website
230
+ - manage all pseudo class : https://html.spec.whatwg.org/multipage/semantics-other.html#selector-hover
201
231
 
202
232
  ## Author
203
233
 
@@ -8,24 +8,6 @@ var React = require('react');
8
8
  var React__default = _interopDefault(React);
9
9
  var styled = _interopDefault(require('styled-components'));
10
10
 
11
- function _extends() {
12
- _extends = Object.assign || function (target) {
13
- for (var i = 1; i < arguments.length; i++) {
14
- var source = arguments[i];
15
-
16
- for (var key in source) {
17
- if (Object.prototype.hasOwnProperty.call(source, key)) {
18
- target[key] = source[key];
19
- }
20
- }
21
- }
22
-
23
- return target;
24
- };
25
-
26
- return _extends.apply(this, arguments);
27
- }
28
-
29
11
  function _inheritsLoose(subClass, superClass) {
30
12
  subClass.prototype = Object.create(superClass.prototype);
31
13
  subClass.prototype.constructor = subClass;
@@ -416,6 +398,109 @@ var ThemeProvider = function ThemeProvider(_ref) {
416
398
  }, children);
417
399
  };
418
400
 
401
+ var shadows = {
402
+ 0: {
403
+ shadowColor: '#000',
404
+ shadowOffset: {
405
+ width: 0,
406
+ height: 1
407
+ },
408
+ shadowOpacity: 0.18,
409
+ shadowRadius: 1.0,
410
+ elevation: 1
411
+ },
412
+ 1: {
413
+ shadowColor: '#000',
414
+ shadowOffset: {
415
+ width: 0,
416
+ height: 1
417
+ },
418
+ shadowOpacity: 0.2,
419
+ shadowRadius: 1.41,
420
+ elevation: 2
421
+ },
422
+ 2: {
423
+ shadowColor: '#000',
424
+ shadowOffset: {
425
+ width: 0,
426
+ height: 1
427
+ },
428
+ shadowOpacity: 0.22,
429
+ shadowRadius: 2.22,
430
+ elevation: 3
431
+ },
432
+ 3: {
433
+ shadowColor: '#000',
434
+ shadowOffset: {
435
+ width: 0,
436
+ height: 2
437
+ },
438
+ shadowOpacity: 0.23,
439
+ shadowRadius: 2.62,
440
+ elevation: 4
441
+ },
442
+ 4: {
443
+ shadowColor: '#000',
444
+ shadowOffset: {
445
+ width: 0,
446
+ height: 2
447
+ },
448
+ shadowOpacity: 0.25,
449
+ shadowRadius: 3.84,
450
+ elevation: 5
451
+ },
452
+ 5: {
453
+ shadowColor: '#000',
454
+ shadowOffset: {
455
+ width: 0,
456
+ height: 3
457
+ },
458
+ shadowOpacity: 0.27,
459
+ shadowRadius: 4.65,
460
+ elevation: 6
461
+ },
462
+ 6: {
463
+ shadowColor: '#000',
464
+ shadowOffset: {
465
+ width: 0,
466
+ height: 3
467
+ },
468
+ shadowOpacity: 0.29,
469
+ shadowRadius: 4.65,
470
+ elevation: 7
471
+ },
472
+ 7: {
473
+ shadowColor: '#000',
474
+ shadowOffset: {
475
+ width: 0,
476
+ height: 4
477
+ },
478
+ shadowOpacity: 0.3,
479
+ shadowRadius: 4.65,
480
+ elevation: 8
481
+ },
482
+ 8: {
483
+ shadowColor: '#000',
484
+ shadowOffset: {
485
+ width: 0,
486
+ height: 4
487
+ },
488
+ shadowOpacity: 0.32,
489
+ shadowRadius: 5.46,
490
+ elevation: 9
491
+ },
492
+ 9: {
493
+ shadowColor: '#000',
494
+ shadowOffset: {
495
+ width: 0,
496
+ height: 5
497
+ },
498
+ shadowOpacity: 0.34,
499
+ shadowRadius: 6.27,
500
+ elevation: 10
501
+ }
502
+ };
503
+
419
504
  var TransformStyleProps = ['transform', 'transformMatrix', 'rotation', 'scaleX', 'scaleY', 'translateX', 'translateY', // 'perspective',
420
505
  // 'rotate',
421
506
  // 'rotateX',
@@ -475,16 +560,41 @@ var applyStyle = function applyStyle(props) {
475
560
  newProps.marginBottom = props.marginVertical;
476
561
  }
477
562
 
478
- Object.keys(props).filter(function (property) {
479
- return StyleProps[property] !== undefined || property[0] == '&';
480
- }).map(function (property) {
481
- newProps[property] = props[property]; // console.log(property, propertyType);
563
+ if (props.shadow) {
564
+ var shawdowValue = typeof props.shadow === 'number' && shadows[props.shadow] !== undefined ? props.shadow : 2;
482
565
 
483
- if (property.toLowerCase().indexOf('color') !== -1) {
484
- newProps[property] = getColor(props[property]);
566
+ if (shadows[shawdowValue]) {
567
+ for (var i in shadows[shawdowValue]) {
568
+ newProps[i] = shadows[shawdowValue][i];
569
+ }
485
570
  }
486
- }); // return {newProps,responsive};
571
+ }
487
572
 
573
+ Object.keys(props).map(function (property) {
574
+ if (StyleProps[property] !== undefined || property == 'on') {
575
+ if (typeof props[property] === 'number' && property !== 'fontWeight') {
576
+ newProps[property] = props[property] + 'px';
577
+ } else if (property.toLowerCase().indexOf('color') !== -1) {
578
+ newProps[property] = getColor(props[property]);
579
+ } else if (typeof props[property] === 'object') {
580
+ if (property === 'on') {
581
+ for (var event in props[property]) {
582
+ newProps['&:' + event] = applyStyle(props[property][event]);
583
+ }
584
+ } else {
585
+ newProps[property] = applyStyle(props[property]);
586
+ }
587
+ } else {
588
+ newProps[property] = props[property];
589
+ }
590
+ } else {
591
+ newProps[property] = props[property];
592
+ }
593
+ });
594
+ console.log({
595
+ props: props,
596
+ newProps: newProps
597
+ });
488
598
  return newProps;
489
599
  }; // function convertToCSS(props: any) {
490
600
  var StyledView = /*#__PURE__*/styled.div(function (props) {
@@ -550,75 +660,8 @@ var Scroll = function Scroll(props) {
550
660
  overflow: 'auto'
551
661
  }, props));
552
662
  };
553
- var Horizontal = function Horizontal(props) {
554
- return React__default.createElement(View, Object.assign({
555
- display: 'flex',
556
- flexDirection: "row"
557
- }, props));
558
- };
559
- var HorizontalScroll = function HorizontalScroll(props) {
560
- return React__default.createElement(Horizontal, Object.assign({
561
- overflowX: "auto"
562
- }, props));
563
- };
564
- var Vertical = function Vertical(props) {
565
- return React__default.createElement(View, Object.assign({
566
- flexDirection: "column"
567
- }, props));
568
- };
569
- var VerticalScroll = function VerticalScroll(props) {
570
- return React__default.createElement(Vertical, Object.assign({
571
- overflowY: "auto"
572
- }, props));
573
- };
574
- var Inline = function Inline(props) {
575
- return React__default.createElement(View, Object.assign({
576
- display: 'flex',
577
- flexDirection: "row",
578
- wordBreak: "break-word"
579
- }, props));
580
- };
581
- var Start = function Start(props) {
582
- return React__default.createElement(View, Object.assign({
583
- display: 'flex',
584
- alignSelf: "flex-start"
585
- }, props));
586
- };
587
- var End = function End(props) {
588
- return React__default.createElement(View, Object.assign({
589
- display: 'flex',
590
- alignSelf: "flex-end"
591
- }, props));
592
- };
593
- var Center = function Center(props) {
594
- return React__default.createElement(View, Object.assign({
595
- display: 'flex',
596
- justifyContent: "center",
597
- alignItems: 'center'
598
- }, props));
599
- };
600
- var AlignStart = function AlignStart(props) {
601
- return React__default.createElement(View, Object.assign({
602
- display: 'flex',
603
- justifyContent: "flex-start"
604
- }, props));
605
- };
606
- var AlignCenter = function AlignCenter(props) {
607
- return React__default.createElement(View, Object.assign({
608
- display: 'flex',
609
- justifyContent: "center",
610
- width: '100%'
611
- }, props));
612
- };
613
- var AlignEnd = function AlignEnd(props) {
614
- return React__default.createElement(View, Object.assign({
615
- display: 'flex',
616
- justifyContent: "flex-end",
617
- width: '100%'
618
- }, props));
619
- };
620
663
 
621
- var _excluded = ["src", "style", "onClick", "onPress"],
664
+ var _excluded = ["src", "onClick", "onPress"],
622
665
  _excluded2 = ["size", "src"],
623
666
  _excluded3 = ["size", "src"];
624
667
  var ImageBackground = /*#__PURE__*/function (_React$PureComponent) {
@@ -633,18 +676,17 @@ var ImageBackground = /*#__PURE__*/function (_React$PureComponent) {
633
676
  _proto.render = function render() {
634
677
  var _this$props = this.props,
635
678
  src = _this$props.src,
636
- style = _this$props.style,
637
679
  onClick = _this$props.onClick,
638
680
  onPress = _this$props.onPress,
639
681
  props = _objectWithoutPropertiesLoose(_this$props, _excluded);
640
682
 
641
683
  return React__default.createElement(View, Object.assign({
642
- style: _extends({
684
+ style: {
643
685
  backgroundSize: 'contain',
644
686
  backgroundImage: "url(\"" + src + "\")",
645
687
  backgroundPosition: 'center center',
646
688
  backgroundRepeat: 'no-repeat'
647
- }, style),
689
+ },
648
690
  onClick: onClick ? onClick : onPress
649
691
  }, props));
650
692
  };
@@ -676,34 +718,7 @@ var SquaredImage = function SquaredImage(_ref2) {
676
718
  }));
677
719
  };
678
720
 
679
- var _excluded$1 = ["hint", "disabled", "opacity", "fontSize"],
680
- _excluded2$1 = ["toUpperCase", "children"];
681
- var formatTextStyle = function formatTextStyle(_ref) {
682
- var _ref$hint = _ref.hint,
683
- hint = _ref$hint === void 0 ? false : _ref$hint,
684
- _ref$disabled = _ref.disabled,
685
- disabled = _ref$disabled === void 0 ? false : _ref$disabled,
686
- opacity = _ref.opacity,
687
- fontSize = _ref.fontSize,
688
- props = _objectWithoutPropertiesLoose(_ref, _excluded$1);
689
-
690
- if (props) {
691
- if (hint) {
692
- opacity = hint;
693
- }
694
-
695
- if (disabled) {
696
- opacity = disabled;
697
- }
698
-
699
- return _extends({}, props, {
700
- opacity: opacity,
701
- fontSize: fontSize
702
- });
703
- }
704
-
705
- return applyStyle(props);
706
- };
721
+ var _excluded$1 = ["toUpperCase", "children"];
707
722
  var TextSpan = /*#__PURE__*/styled.div(function (props) {
708
723
  props.display = 'inherit';
709
724
  props.flexDirection = 'column';
@@ -723,7 +738,7 @@ var Text = /*#__PURE__*/function (_React$PureComponent) {
723
738
  _this$props$toUpperCa = _this$props.toUpperCase,
724
739
  toUpperCase = _this$props$toUpperCa === void 0 ? false : _this$props$toUpperCa,
725
740
  children = _this$props.children,
726
- props = _objectWithoutPropertiesLoose(_this$props, _excluded2$1);
741
+ props = _objectWithoutPropertiesLoose(_this$props, _excluded$1);
727
742
 
728
743
  var content = children;
729
744
 
@@ -862,32 +877,20 @@ var useResponsive = function useResponsive() {
862
877
  };
863
878
  };
864
879
 
865
- exports.AlignCenter = AlignCenter;
866
- exports.AlignEnd = AlignEnd;
867
- exports.AlignStart = AlignStart;
868
- exports.Center = Center;
869
- exports.End = End;
870
- exports.Horizontal = Horizontal;
871
- exports.HorizontalScroll = HorizontalScroll;
872
880
  exports.Image = Image;
873
881
  exports.ImageBackground = ImageBackground;
874
- exports.Inline = Inline;
875
882
  exports.ResponsiveContext = ResponsiveContext;
876
883
  exports.ResponsiveProvider = ResponsiveProvider;
877
884
  exports.RoundedImage = RoundedImage;
878
885
  exports.SafeArea = SafeArea;
879
886
  exports.Scroll = Scroll;
880
887
  exports.SquaredImage = SquaredImage;
881
- exports.Start = Start;
882
888
  exports.Text = Text;
883
889
  exports.TextSpan = TextSpan;
884
890
  exports.ThemeContext = ThemeContext;
885
891
  exports.ThemeProvider = ThemeProvider;
886
- exports.Vertical = Vertical;
887
- exports.VerticalScroll = VerticalScroll;
888
892
  exports.View = View;
889
893
  exports.createQuery = createQuery;
890
- exports.formatTextStyle = formatTextStyle;
891
894
  exports.useMount = useMount;
892
895
  exports.useResponsive = useResponsive;
893
896
  exports.useResponsiveContext = useResponsiveContext;