app-studio 0.0.1 → 0.0.5

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
 
@@ -6,26 +6,9 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'defau
6
6
 
7
7
  var React = require('react');
8
8
  var React__default = _interopDefault(React);
9
+ var Color = _interopDefault(require('color-convert'));
9
10
  var styled = _interopDefault(require('styled-components'));
10
11
 
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
12
  function _inheritsLoose(subClass, superClass) {
30
13
  subClass.prototype = Object.create(superClass.prototype);
31
14
  subClass.prototype.constructor = subClass;
@@ -416,6 +399,99 @@ var ThemeProvider = function ThemeProvider(_ref) {
416
399
  }, children);
417
400
  };
418
401
 
402
+ var shadows = {
403
+ 0: {
404
+ shadowColor: '#000',
405
+ shadowOffset: {
406
+ width: 0,
407
+ height: 1
408
+ },
409
+ shadowOpacity: 0.18,
410
+ shadowRadius: 1.0
411
+ },
412
+ 1: {
413
+ shadowColor: '#000',
414
+ shadowOffset: {
415
+ width: 0,
416
+ height: 1
417
+ },
418
+ shadowOpacity: 0.2,
419
+ shadowRadius: 1.41
420
+ },
421
+ 2: {
422
+ shadowColor: '#000',
423
+ shadowOffset: {
424
+ width: 0,
425
+ height: 1
426
+ },
427
+ shadowOpacity: 0.22,
428
+ shadowRadius: 2.22
429
+ },
430
+ 3: {
431
+ shadowColor: '#000',
432
+ shadowOffset: {
433
+ width: 0,
434
+ height: 2
435
+ },
436
+ shadowOpacity: 0.23,
437
+ shadowRadius: 2.62
438
+ },
439
+ 4: {
440
+ shadowColor: '#000',
441
+ shadowOffset: {
442
+ width: 0,
443
+ height: 2
444
+ },
445
+ shadowOpacity: 0.25,
446
+ shadowRadius: 3.84
447
+ },
448
+ 5: {
449
+ shadowColor: '#000',
450
+ shadowOffset: {
451
+ width: 0,
452
+ height: 3
453
+ },
454
+ shadowOpacity: 0.27,
455
+ shadowRadius: 4.65
456
+ },
457
+ 6: {
458
+ shadowColor: '#000',
459
+ shadowOffset: {
460
+ width: 0,
461
+ height: 3
462
+ },
463
+ shadowOpacity: 0.29,
464
+ shadowRadius: 4.65
465
+ },
466
+ 7: {
467
+ shadowColor: '#000',
468
+ shadowOffset: {
469
+ width: 0,
470
+ height: 4
471
+ },
472
+ shadowOpacity: 0.3,
473
+ shadowRadius: 4.65
474
+ },
475
+ 8: {
476
+ shadowColor: '#000',
477
+ shadowOffset: {
478
+ width: 0,
479
+ height: 4
480
+ },
481
+ shadowOpacity: 0.32,
482
+ shadowRadius: 5.46
483
+ },
484
+ 9: {
485
+ shadowColor: '#000',
486
+ shadowOffset: {
487
+ width: 0,
488
+ height: 5
489
+ },
490
+ shadowOpacity: 0.34,
491
+ shadowRadius: 6.27
492
+ }
493
+ };
494
+
419
495
  var TransformStyleProps = ['transform', 'transformMatrix', 'rotation', 'scaleX', 'scaleY', 'translateX', 'translateY', // 'perspective',
420
496
  // 'rotate',
421
497
  // 'rotateX',
@@ -475,16 +551,38 @@ var applyStyle = function applyStyle(props) {
475
551
  newProps.marginBottom = props.marginVertical;
476
552
  }
477
553
 
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);
554
+ if (props.shadow) {
555
+ if (typeof props.shadow === 'number' || typeof props.shadow === 'boolean') {
556
+ var shawdowValue = typeof props.shadow === 'number' && shadows[props.shadow] !== undefined ? props.shadow : 2;
482
557
 
483
- if (property.toLowerCase().indexOf('color') !== -1) {
484
- newProps[property] = getColor(props[property]);
558
+ if (shadows[shawdowValue]) {
559
+ var shadowColor = Color.hex.rgb(shadows[shawdowValue].shadowColor).join(',');
560
+ newProps['boxShadow'] = shadows[shawdowValue].shadowOffset.height + "px " + shadows[shawdowValue].shadowOffset.width + "px " + shadows[shawdowValue].shadowRadius + "px rgba(" + shadowColor + "," + shadows[shawdowValue].shadowOpacity + ")";
561
+ }
562
+ } else {
563
+ var _shadowColor = Color.hex.rgb(props.shadow.shadowColor).join(',');
564
+
565
+ newProps['boxShadow'] = props.shadow.shadowOffset.height + "px " + props.shadow.shadowOffset.width + "px " + props.shadow.shadowRadius + "px rgba(" + _shadowColor + "," + props.shadow.shadowOpacity + ")";
485
566
  }
486
- }); // return {newProps,responsive};
567
+ }
487
568
 
569
+ Object.keys(props).map(function (property) {
570
+ if (StyleProps[property] !== undefined || property == 'on') {
571
+ if (property.toLowerCase().indexOf('color') !== -1) {
572
+ newProps[property] = getColor(props[property]);
573
+ } else if (typeof props[property] === 'object') {
574
+ if (property === 'on') {
575
+ for (var event in props[property]) {
576
+ newProps['&:' + event] = applyStyle(props[property][event]);
577
+ }
578
+ } else {
579
+ newProps[property] = applyStyle(props[property]);
580
+ }
581
+ } else {
582
+ newProps[property] = props[property];
583
+ }
584
+ }
585
+ });
488
586
  return newProps;
489
587
  }; // function convertToCSS(props: any) {
490
588
  // return Object.entries(props).reduce((str, [key, val]) => {
@@ -593,75 +691,8 @@ var Scroll = function Scroll(props) {
593
691
  overflow: 'auto'
594
692
  }, props));
595
693
  };
596
- var Horizontal = function Horizontal(props) {
597
- return React__default.createElement(View, Object.assign({
598
- display: 'flex',
599
- flexDirection: "row"
600
- }, props));
601
- };
602
- var HorizontalScroll = function HorizontalScroll(props) {
603
- return React__default.createElement(Horizontal, Object.assign({
604
- overflowX: "auto"
605
- }, props));
606
- };
607
- var Vertical = function Vertical(props) {
608
- return React__default.createElement(View, Object.assign({
609
- flexDirection: "column"
610
- }, props));
611
- };
612
- var VerticalScroll = function VerticalScroll(props) {
613
- return React__default.createElement(Vertical, Object.assign({
614
- overflowY: "auto"
615
- }, props));
616
- };
617
- var Inline = function Inline(props) {
618
- return React__default.createElement(View, Object.assign({
619
- display: 'flex',
620
- flexDirection: "row",
621
- wordBreak: "break-word"
622
- }, props));
623
- };
624
- var Start = function Start(props) {
625
- return React__default.createElement(View, Object.assign({
626
- display: 'flex',
627
- alignSelf: "flex-start"
628
- }, props));
629
- };
630
- var End = function End(props) {
631
- return React__default.createElement(View, Object.assign({
632
- display: 'flex',
633
- alignSelf: "flex-end"
634
- }, props));
635
- };
636
- var Center = function Center(props) {
637
- return React__default.createElement(View, Object.assign({
638
- display: 'flex',
639
- justifyContent: "center",
640
- alignItems: 'center'
641
- }, props));
642
- };
643
- var AlignStart = function AlignStart(props) {
644
- return React__default.createElement(View, Object.assign({
645
- display: 'flex',
646
- justifyContent: "flex-start"
647
- }, props));
648
- };
649
- var AlignCenter = function AlignCenter(props) {
650
- return React__default.createElement(View, Object.assign({
651
- display: 'flex',
652
- justifyContent: "center",
653
- width: '100%'
654
- }, props));
655
- };
656
- var AlignEnd = function AlignEnd(props) {
657
- return React__default.createElement(View, Object.assign({
658
- display: 'flex',
659
- justifyContent: "flex-end",
660
- width: '100%'
661
- }, props));
662
- };
663
694
 
664
- var _excluded = ["src", "style", "onClick", "onPress"],
695
+ var _excluded = ["src", "onClick", "onPress"],
665
696
  _excluded2 = ["size", "src"],
666
697
  _excluded3 = ["size", "src"];
667
698
  var ImageBackground = /*#__PURE__*/function (_React$PureComponent) {
@@ -676,18 +707,17 @@ var ImageBackground = /*#__PURE__*/function (_React$PureComponent) {
676
707
  _proto.render = function render() {
677
708
  var _this$props = this.props,
678
709
  src = _this$props.src,
679
- style = _this$props.style,
680
710
  onClick = _this$props.onClick,
681
711
  onPress = _this$props.onPress,
682
712
  props = _objectWithoutPropertiesLoose(_this$props, _excluded);
683
713
 
684
714
  return React__default.createElement(View, Object.assign({
685
- style: _extends({
715
+ style: {
686
716
  backgroundSize: 'contain',
687
717
  backgroundImage: "url(\"" + src + "\")",
688
718
  backgroundPosition: 'center center',
689
719
  backgroundRepeat: 'no-repeat'
690
- }, style),
720
+ },
691
721
  onClick: onClick ? onClick : onPress
692
722
  }, props));
693
723
  };
@@ -719,83 +749,53 @@ var SquaredImage = function SquaredImage(_ref2) {
719
749
  }));
720
750
  };
721
751
 
722
- var _excluded$1 = ["hint", "disabled", "opacity", "fontSize"],
723
- _excluded2$1 = ["toUpperCase", "children", "textTypographyConfig"];
724
- var formatTextStyle = function formatTextStyle(_ref) {
725
- var _ref$hint = _ref.hint,
726
- hint = _ref$hint === void 0 ? false : _ref$hint,
727
- _ref$disabled = _ref.disabled,
728
- disabled = _ref$disabled === void 0 ? false : _ref$disabled,
729
- opacity = _ref.opacity,
730
- fontSize = _ref.fontSize,
731
- props = _objectWithoutPropertiesLoose(_ref, _excluded$1);
732
-
733
- if (props) {
734
- if (hint) {
735
- opacity = hint;
736
- }
737
-
738
- if (disabled) {
739
- opacity = disabled;
740
- }
741
-
742
- return _extends({}, props, {
743
- opacity: opacity,
744
- fontSize: fontSize
745
- });
746
- }
747
-
748
- return props;
749
- };
752
+ var _excluded$1 = ["toUpperCase", "children", "toFormat"];
750
753
  var TextSpan = /*#__PURE__*/styled.div(function (props) {
751
754
  props.display = 'inherit';
752
755
  props.flexDirection = 'column';
753
756
  return applyStyle(props);
754
757
  });
755
- var TextComponent = function TextComponent(textProps) {
756
- var _useTheme = useTheme(),
757
- getColor = _useTheme.getColor;
758
+ var Text = /*#__PURE__*/function (_React$PureComponent) {
759
+ _inheritsLoose(Text, _React$PureComponent);
758
760
 
759
- var styledProps = applyStyle(textProps);
761
+ function Text() {
762
+ return _React$PureComponent.apply(this, arguments) || this;
763
+ }
760
764
 
761
- var _styledProps$toUpperC = styledProps.toUpperCase,
762
- toUpperCase = _styledProps$toUpperC === void 0 ? false : _styledProps$toUpperC,
763
- children = styledProps.children,
764
- textTypographyConfig = styledProps.textTypographyConfig,
765
- props = _objectWithoutPropertiesLoose(styledProps, _excluded2$1);
765
+ var _proto = Text.prototype;
766
766
 
767
- var content = children;
767
+ _proto.render = function render() {
768
+ var _this$props = this.props,
769
+ _this$props$toUpperCa = _this$props.toUpperCase,
770
+ toUpperCase = _this$props$toUpperCa === void 0 ? false : _this$props$toUpperCa,
771
+ children = _this$props.children,
772
+ _this$props$toFormat = _this$props.toFormat,
773
+ toFormat = _this$props$toFormat === void 0 ? false : _this$props$toFormat,
774
+ props = _objectWithoutPropertiesLoose(_this$props, _excluded$1);
768
775
 
769
- if (children && typeof children === 'string') {
770
- content = children.toString().trim();
771
- }
776
+ var content = children;
772
777
 
773
- if (typeof content === 'string' && toUpperCase) {
774
- content = content.toUpperCase();
775
- }
778
+ if (children && typeof children === 'string') {
779
+ content = children.toString().trim();
780
+ }
776
781
 
777
- var style = props.style || {};
782
+ if (typeof content === 'string' && toUpperCase) {
783
+ content = content.toUpperCase();
784
+ }
778
785
 
779
- if (textTypographyConfig) {
780
- style = formatTextStyle(_extends({}, textTypographyConfig, style));
781
- }
786
+ if (typeof content === 'string' && toFormat) {
787
+ content = content.split('\n').map(function (item, key) {
788
+ return React__default.createElement("span", {
789
+ key: key.toString()
790
+ }, item, React__default.createElement("br", null));
791
+ });
792
+ }
782
793
 
783
- if (typeof content === 'string') {
784
- content = content.split('\n').map(function (item, key) {
785
- return React__default.createElement("span", {
786
- key: key.toString()
787
- }, item, React__default.createElement("br", null));
788
- });
789
- }
794
+ return React__default.createElement(TextSpan, Object.assign({}, props), content);
795
+ };
790
796
 
791
- Object.values(style).map(function (val) {
792
- if (typeof val === 'string' && val.toLowerCase().indexOf('color') !== -1) {
793
- val = getColor(val);
794
- }
795
- });
796
- return React__default.createElement(TextSpan, Object.assign({}, style, props), content);
797
- };
798
- var Text = TextComponent;
797
+ return Text;
798
+ }(React__default.PureComponent);
799
799
 
800
800
  var useMount = function useMount(callback) {
801
801
  React.useEffect(function () {
@@ -910,33 +910,20 @@ var useResponsive = function useResponsive() {
910
910
  };
911
911
  };
912
912
 
913
- exports.AlignCenter = AlignCenter;
914
- exports.AlignEnd = AlignEnd;
915
- exports.AlignStart = AlignStart;
916
- exports.Center = Center;
917
- exports.End = End;
918
- exports.Horizontal = Horizontal;
919
- exports.HorizontalScroll = HorizontalScroll;
920
913
  exports.Image = Image;
921
914
  exports.ImageBackground = ImageBackground;
922
- exports.Inline = Inline;
923
915
  exports.ResponsiveContext = ResponsiveContext;
924
916
  exports.ResponsiveProvider = ResponsiveProvider;
925
917
  exports.RoundedImage = RoundedImage;
926
918
  exports.SafeArea = SafeArea;
927
919
  exports.Scroll = Scroll;
928
920
  exports.SquaredImage = SquaredImage;
929
- exports.Start = Start;
930
921
  exports.Text = Text;
931
- exports.TextComponent = TextComponent;
932
922
  exports.TextSpan = TextSpan;
933
923
  exports.ThemeContext = ThemeContext;
934
924
  exports.ThemeProvider = ThemeProvider;
935
- exports.Vertical = Vertical;
936
- exports.VerticalScroll = VerticalScroll;
937
925
  exports.View = View;
938
926
  exports.createQuery = createQuery;
939
- exports.formatTextStyle = formatTextStyle;
940
927
  exports.useMount = useMount;
941
928
  exports.useResponsive = useResponsive;
942
929
  exports.useResponsiveContext = useResponsiveContext;