react-text-typing 0.1.0 → 0.2.0

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
@@ -1,5 +1,6 @@
1
- # React text Typing
1
+ # React text typing
2
2
 
3
+ > Component that performs the effect of writing
3
4
 
4
5
  [![CircleCI](https://circleci.com/gh/Oda2/react-text-typing.svg?style=shield)](https://circleci.com/gh/Oda2/react-text-typing)
5
6
  [![Coverage Status](https://coveralls.io/repos/github/Oda2/react-text-typing/badge.svg?branch=master)](https://coveralls.io/github/Oda2/react-text-typing?branch=master)
@@ -8,6 +9,7 @@
8
9
  [![GitHub issues](https://img.shields.io/github/issues/Oda2/react-text-typing)](https://github.com/Oda2/react-text-typing/issues)
9
10
  [![GitHub stars](https://img.shields.io/github/stars/Oda2/react-text-typing)](https://github.com/Oda2/react-text-typing/stargazers)
10
11
  [![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2FOda2%2Freact-text-typing.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2FOda2%2Freact-text-typing?ref=badge_shield)
12
+ [![react-text-typing](https://img.shields.io/endpoint?url=https://dashboard.cypress.io/badge/simple/mp85fc/main&style=flat&logo=cypress)](https://dashboard.cypress.io/projects/mp85fc/runs)
11
13
  [![Edit admiring-sun-5qry6](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/admiring-sun-5qry6?fontsize=14&hidenavigation=1&theme=dark)
12
14
 
13
15
  ## Installation
@@ -21,7 +23,7 @@ $ yarn add react-text-typing
21
23
  ```
22
24
 
23
25
  ## Demo
24
- ![Exemple](./docs/example.gif)
26
+ ![Exemple](https://raw.githubusercontent.com/Oda2/react-text-typing/main/docs/example.gif)
25
27
 
26
28
  ## Examples
27
29
 
@@ -13,25 +13,36 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
13
13
 
14
14
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
15
15
 
16
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
17
-
18
16
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
19
17
 
18
+ var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
19
+
20
20
  var _react = _interopRequireWildcard(require("react"));
21
21
 
22
22
  var _propTypes = _interopRequireDefault(require("prop-types"));
23
23
 
24
- var _reactJss = require("react-jss");
24
+ var _styledComponents = _interopRequireWildcard(require("styled-components"));
25
25
 
26
26
  var _excluded = ["text", "showBlink", "speed", "component"];
27
27
 
28
+ var _templateObject, _templateObject2, _templateObject3;
29
+
28
30
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
29
31
 
30
32
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
31
33
 
32
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
33
-
34
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
34
+ var blinking = (0, _styledComponents.keyframes)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n0% {\n border-color: transparent;\n};\n \n50% {\n border-color: black;\n}\n"])));
35
+ var loading = (0, _styledComponents.keyframes)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n0% {\n max-width: 0%;\n}\n"])));
36
+
37
+ var TextRoot = _styledComponents.default.span(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\nposition: relative;\ncolor: ", ";\nfont-size: 5em;\nmargin: 0;\npadding: 0;\nborder-right: .1em solid;\nanimation: ", " 0.8s linear infinite;\n\n&::before {\n content: '", "';\n position: absolute;\n overflow: hidden;\n white-space: nowrap;\n animation: ", " ", "s steps(80);\n max-width: 100%;\n color: ", ";\n}\n"])), function (props) {
38
+ return props.colorText;
39
+ }, blinking, function (props) {
40
+ return props.internalText;
41
+ }, loading, function (props) {
42
+ return props.timeTyping;
43
+ }, function (props) {
44
+ return props.colorTyping;
45
+ });
35
46
 
36
47
  var TextTyping = function TextTyping(_ref) {
37
48
  var text = _ref.text,
@@ -39,7 +50,6 @@ var TextTyping = function TextTyping(_ref) {
39
50
  speed = _ref.speed,
40
51
  Component = _ref.component,
41
52
  props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
42
- var classes = useStyles(_objectSpread({}, props));
43
53
 
44
54
  var _useState = (0, _react.useState)(''),
45
55
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
@@ -61,56 +71,13 @@ var TextTyping = function TextTyping(_ref) {
61
71
  }, speed);
62
72
  return function () {};
63
73
  }, [text]);
64
- return /*#__PURE__*/_react.default.createElement(Component, (0, _extends2.default)({
65
- className: "".concat(classes.text, " ").concat(showBlink ? classes.blink : ''),
66
- "data-text": internalText
74
+ return /*#__PURE__*/_react.default.createElement(TextRoot, (0, _extends2.default)({
75
+ as: Component,
76
+ "data-text": text,
77
+ internalText: internalText
67
78
  }, props), internalText);
68
79
  };
69
80
 
70
- var useStyles = (0, _reactJss.createUseStyles)({
71
- text: {
72
- position: 'relative',
73
- color: function color(props) {
74
- return props.colorText;
75
- },
76
- fontSize: '5em',
77
- '&:before': {
78
- content: 'attr(data-text)',
79
- position: 'absolute',
80
- overflow: 'hidden',
81
- whiteSpace: 'nowrap',
82
- animation: '$loading 5s steps(80)',
83
- maxWidth: '100%',
84
- color: function color(props) {
85
- return props.colorTyping;
86
- }
87
- }
88
- },
89
- '@keyframes typing': {
90
- from: {
91
- width: 0
92
- }
93
- },
94
- '@keyframes blinking': {
95
- '0%': {
96
- borderColor: 'transparent'
97
- },
98
- '50%': {
99
- borderColor: 'black'
100
- }
101
- },
102
- '@keyframes loading': {
103
- '0%': {
104
- maxWidth: 0
105
- }
106
- },
107
- blink: {
108
- margin: 0,
109
- padding: 0,
110
- borderRight: '.1em solid',
111
- animation: '$blinking 0.8s linear infinite'
112
- }
113
- });
114
81
  TextTyping.propTypes = {
115
82
  /** Text to be demonstrated in the component */
116
83
  text: _propTypes.default.string.isRequired,
@@ -128,14 +95,18 @@ TextTyping.propTypes = {
128
95
  showBlink: _propTypes.default.bool,
129
96
 
130
97
  /** Text speed appearing */
131
- speed: _propTypes.default.number
98
+ speed: _propTypes.default.number,
99
+
100
+ /** Time typing in animation */
101
+ timeTyping: _propTypes.default.number
132
102
  };
133
103
  TextTyping.defaultProps = {
134
104
  component: 'h1',
135
105
  showBlink: true,
136
106
  colorText: '#FFF',
137
107
  colorTyping: '#0075D7',
138
- speed: 500
108
+ speed: 500,
109
+ timeTyping: 10
139
110
  };
140
111
  var _default = TextTyping;
141
112
  exports.default = _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-text-typing",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -16,7 +16,8 @@
16
16
  },
17
17
  "keywords": [
18
18
  "react",
19
- "library"
19
+ "library",
20
+ "styled-components"
20
21
  ],
21
22
  "bugs": {
22
23
  "url": "https://github.com/oda2/react-text-typing/issues"
@@ -34,18 +35,18 @@
34
35
  "cypress": "$(yarn bin)/cypress"
35
36
  },
36
37
  "devDependencies": {
37
- "@babel/eslint-parser": "^7.17.0",
38
+ "@babel/eslint-parser": "^7.18.2",
38
39
  "@testing-library/jest-dom": "^5.16.4",
39
- "@testing-library/react": "^13.1.1",
40
+ "@testing-library/react": "^13.3.0",
40
41
  "coveralls": "^3.1.1",
41
- "cypress": "^9.5.4",
42
- "eslint": "^8.13.0",
43
- "eslint-plugin-jsx-a11y": "^6.5.1",
44
- "eslint-plugin-react": "^7.29.4",
42
+ "cypress": "^10.3.0",
43
+ "eslint": "^8.19.0",
44
+ "eslint-plugin-jsx-a11y": "^6.6.0",
45
+ "eslint-plugin-react": "^7.30.1",
45
46
  "prop-types": "^15.8.1",
46
- "react": "^18.0.0",
47
+ "react": "^18.2.0",
47
48
  "react-dependency-scripts": "^1.0.6",
48
- "react-dom": "^18.0.0"
49
+ "react-dom": "^18.2.0"
49
50
  },
50
51
  "browserslist": {
51
52
  "production": [
@@ -60,7 +61,7 @@
60
61
  ]
61
62
  },
62
63
  "dependencies": {
63
- "react-jss": "^10.9.0"
64
+ "styled-components": "^5.3.5"
64
65
  },
65
66
  "jest": {
66
67
  "testMatch": [