app-studio 0.0.2 → 0.0.6

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',
@@ -436,6 +512,11 @@ var StyleProps = {};
436
512
  allStyleProps.map(function (property) {
437
513
  StyleProps[property] = true;
438
514
  });
515
+ var NumberPropsStyle = {};
516
+ var NumberProps = ['numberOfLines', 'fontWeight', 'timeStamp', 'flex', 'flexGrow', 'flexShrink', 'order', 'zIndex', 'aspectRatio', 'shadowOpacity', 'shadowRadius', 'scale', 'opacity', 'min', 'max', 'now'];
517
+ NumberProps.map(function (property) {
518
+ NumberPropsStyle[property] = true;
519
+ });
439
520
  var setSize = function setSize(newSize, newProps) {
440
521
  newProps.height = newProps.width = newSize;
441
522
  };
@@ -475,18 +556,85 @@ var applyStyle = function applyStyle(props) {
475
556
  newProps.marginBottom = props.marginVertical;
476
557
  }
477
558
 
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);
559
+ if (props.shadow) {
560
+ if (typeof props.shadow === 'number' || typeof props.shadow === 'boolean') {
561
+ var shawdowValue = typeof props.shadow === 'number' && shadows[props.shadow] !== undefined ? props.shadow : 2;
482
562
 
483
- if (property.toLowerCase().indexOf('color') !== -1) {
484
- newProps[property] = getColor(props[property]);
563
+ if (shadows[shawdowValue]) {
564
+ var shadowColor = Color.hex.rgb(shadows[shawdowValue].shadowColor).join(',');
565
+ newProps['boxShadow'] = shadows[shawdowValue].shadowOffset.height + "px " + shadows[shawdowValue].shadowOffset.width + "px " + shadows[shawdowValue].shadowRadius + "px rgba(" + shadowColor + "," + shadows[shawdowValue].shadowOpacity + ")";
566
+ }
567
+ } else {
568
+ var _shadowColor = Color.hex.rgb(props.shadow.shadowColor).join(',');
569
+
570
+ newProps['boxShadow'] = props.shadow.shadowOffset.height + "px " + props.shadow.shadowOffset.width + "px " + props.shadow.shadowRadius + "px rgba(" + _shadowColor + "," + props.shadow.shadowOpacity + ")";
485
571
  }
486
- }); // return {newProps,responsive};
572
+ }
487
573
 
574
+ Object.keys(props).map(function (property) {
575
+ if (StyleProps[property] !== undefined || property == 'on') {
576
+ if (typeof props[property] === 'number' && NumberPropsStyle[property] === undefined) {
577
+ newProps[property] = props[property] + 'px';
578
+ } else if (property.toLowerCase().indexOf('color') !== -1) {
579
+ newProps[property] = getColor(props[property]);
580
+ } else if (typeof props[property] === 'object') {
581
+ if (property === 'on') {
582
+ for (var event in props[property]) {
583
+ newProps['&:' + event] = applyStyle(props[property][event]);
584
+ }
585
+ } else {
586
+ newProps[property] = applyStyle(props[property]);
587
+ }
588
+ } else {
589
+ newProps[property] = props[property];
590
+ }
591
+ }
592
+ });
488
593
  return newProps;
489
594
  }; // function convertToCSS(props: any) {
595
+ // return Object.entries(props).reduce((str, [key, val]) => {
596
+ // const casedKey = key.replace(
597
+ // /[A-Z]/g,
598
+ // (match) => `-${match.toLowerCase()}`
599
+ // );
600
+ // return `${str}${casedKey}:${typeof val === 'number' ? val + 'px' : val};\n`;
601
+ // }, '');
602
+ // }
603
+ // export const getResponsiveMediaQueries = (props: any) => {
604
+ // const { breakpointKeys, breakpoints } = useResponsive();
605
+ // console.log('mediaQueries', props);
606
+ // const mediaQueries = breakpointKeys
607
+ // .map((size) => {
608
+ // return props && props[size] !== undefined
609
+ // ? `
610
+ // @media ${
611
+ // breakpoints[size].min
612
+ // ? ' (min-width:' +
613
+ // (breakpoints[size].min > 0 ? breakpoints[size].min : 0) +
614
+ // 'px)'
615
+ // : ''
616
+ // } ${
617
+ // breakpoints[size].min &&
618
+ // breakpoints[size].max &&
619
+ // breakpoints[size].max >= 0 &&
620
+ // breakpoints[size].max < Infinity
621
+ // ? ' and '
622
+ // : ''
623
+ // } ${
624
+ // breakpoints[size].max &&
625
+ // breakpoints[size].max >= 0 &&
626
+ // breakpoints[size].max < Infinity
627
+ // ? ' (max-width:' + breakpoints[size].max + 'px)'
628
+ // : ''
629
+ // } {
630
+ // ${convertToCSS(props[size])}
631
+ // }`
632
+ // : '';
633
+ // })
634
+ // .join('\n');
635
+ // return mediaQueries;
636
+ // };
637
+
490
638
  var StyledView = /*#__PURE__*/styled.div(function (props) {
491
639
  return applyStyle(props);
492
640
  });
@@ -550,75 +698,8 @@ var Scroll = function Scroll(props) {
550
698
  overflow: 'auto'
551
699
  }, props));
552
700
  };
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
701
 
621
- var _excluded = ["src", "style", "onClick", "onPress"],
702
+ var _excluded = ["src", "onClick", "onPress"],
622
703
  _excluded2 = ["size", "src"],
623
704
  _excluded3 = ["size", "src"];
624
705
  var ImageBackground = /*#__PURE__*/function (_React$PureComponent) {
@@ -633,18 +714,17 @@ var ImageBackground = /*#__PURE__*/function (_React$PureComponent) {
633
714
  _proto.render = function render() {
634
715
  var _this$props = this.props,
635
716
  src = _this$props.src,
636
- style = _this$props.style,
637
717
  onClick = _this$props.onClick,
638
718
  onPress = _this$props.onPress,
639
719
  props = _objectWithoutPropertiesLoose(_this$props, _excluded);
640
720
 
641
721
  return React__default.createElement(View, Object.assign({
642
- style: _extends({
722
+ style: {
643
723
  backgroundSize: 'contain',
644
724
  backgroundImage: "url(\"" + src + "\")",
645
725
  backgroundPosition: 'center center',
646
726
  backgroundRepeat: 'no-repeat'
647
- }, style),
727
+ },
648
728
  onClick: onClick ? onClick : onPress
649
729
  }, props));
650
730
  };
@@ -676,34 +756,7 @@ var SquaredImage = function SquaredImage(_ref2) {
676
756
  }));
677
757
  };
678
758
 
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
- };
759
+ var _excluded$1 = ["toUpperCase", "children", "toFormat"];
707
760
  var TextSpan = /*#__PURE__*/styled.div(function (props) {
708
761
  props.display = 'inherit';
709
762
  props.flexDirection = 'column';
@@ -723,7 +776,9 @@ var Text = /*#__PURE__*/function (_React$PureComponent) {
723
776
  _this$props$toUpperCa = _this$props.toUpperCase,
724
777
  toUpperCase = _this$props$toUpperCa === void 0 ? false : _this$props$toUpperCa,
725
778
  children = _this$props.children,
726
- props = _objectWithoutPropertiesLoose(_this$props, _excluded2$1);
779
+ _this$props$toFormat = _this$props.toFormat,
780
+ toFormat = _this$props$toFormat === void 0 ? false : _this$props$toFormat,
781
+ props = _objectWithoutPropertiesLoose(_this$props, _excluded$1);
727
782
 
728
783
  var content = children;
729
784
 
@@ -735,7 +790,7 @@ var Text = /*#__PURE__*/function (_React$PureComponent) {
735
790
  content = content.toUpperCase();
736
791
  }
737
792
 
738
- if (typeof content === 'string') {
793
+ if (typeof content === 'string' && toFormat) {
739
794
  content = content.split('\n').map(function (item, key) {
740
795
  return React__default.createElement("span", {
741
796
  key: key.toString()
@@ -862,32 +917,20 @@ var useResponsive = function useResponsive() {
862
917
  };
863
918
  };
864
919
 
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
920
  exports.Image = Image;
873
921
  exports.ImageBackground = ImageBackground;
874
- exports.Inline = Inline;
875
922
  exports.ResponsiveContext = ResponsiveContext;
876
923
  exports.ResponsiveProvider = ResponsiveProvider;
877
924
  exports.RoundedImage = RoundedImage;
878
925
  exports.SafeArea = SafeArea;
879
926
  exports.Scroll = Scroll;
880
927
  exports.SquaredImage = SquaredImage;
881
- exports.Start = Start;
882
928
  exports.Text = Text;
883
929
  exports.TextSpan = TextSpan;
884
930
  exports.ThemeContext = ThemeContext;
885
931
  exports.ThemeProvider = ThemeProvider;
886
- exports.Vertical = Vertical;
887
- exports.VerticalScroll = VerticalScroll;
888
932
  exports.View = View;
889
933
  exports.createQuery = createQuery;
890
- exports.formatTextStyle = formatTextStyle;
891
934
  exports.useMount = useMount;
892
935
  exports.useResponsive = useResponsive;
893
936
  exports.useResponsiveContext = useResponsiveContext;