diff --git a/apps/docs/src/pages/docs/_meta.json b/apps/docs/src/pages/docs/_meta.json index 9ff5ce4..bdbb8dc 100644 --- a/apps/docs/src/pages/docs/_meta.json +++ b/apps/docs/src/pages/docs/_meta.json @@ -7,6 +7,9 @@ "phone-input": { "title": "PhoneInput" }, + "animated-text": { + "title": "AnimatedText" + }, "-- Hooks": { "type": "separator", "title": "Hooks" diff --git a/apps/docs/src/pages/docs/animated-text.mdx b/apps/docs/src/pages/docs/animated-text.mdx new file mode 100644 index 0000000..4e18ff3 --- /dev/null +++ b/apps/docs/src/pages/docs/animated-text.mdx @@ -0,0 +1,32 @@ +--- +title: AnimatedText +--- + +# AnimatedText + +**AnimatedText** is a animated customizable React Component. + +## Install + +To start using **AnimatedText**, you can install the `@react-awesome/use-breakpoint` library or you can import it directly from `@react-awesome/components` if you have installed it before. In your project directory, run +the following command to install the dependencies: + +```sh npm2yarn +npm i @react-awesome/components +``` + +## Usage + +import { useState } from 'react' +import { Container } from '../../components/Container' +import { AnimatedText } from '@react-awesome/components' + +export const TypeWritter = () => { + return +} + +**AnimtedText** can support animate as `typewriter` effect. + + + + diff --git a/packages/animated-text/.eslintrc.js b/packages/animated-text/.eslintrc.js new file mode 100644 index 0000000..19f3ed1 --- /dev/null +++ b/packages/animated-text/.eslintrc.js @@ -0,0 +1,8 @@ +module.exports = { + root: true, + extends: ["@react-awesome/eslint-config/library.js"], + parser: "@typescript-eslint/parser", + parserOptions: { + project: true, + }, +}; diff --git a/packages/animated-text/README.md b/packages/animated-text/README.md new file mode 100644 index 0000000..911ac69 --- /dev/null +++ b/packages/animated-text/README.md @@ -0,0 +1,32 @@ +# @react-awesome/animated-text + +

+ version + coverage + license + build status + size +

+ +**animated-text** tracks the previous value of a variable. + +Please refer to the [documentation](https://react-awesome-components.vercel.app/docs/animated-text) for more information. + +## Installation + +```sh +yarn add @react-awesome/animated-text +# or +npm i @react-awesome/animated-text +``` + +## Contribution + +Yes please! See the +[contributing guidelines](https://github.com/trinhthinh388/react-awesome-components/blob/master/CONTRIBUTING.md) +for details. + +## Licence + +This project is licensed under the terms of the +[MIT license](https://github.com/trinhthinh388/react-awesome-components/blob/master/LICENSE). diff --git a/packages/animated-text/package.json b/packages/animated-text/package.json new file mode 100644 index 0000000..e70290d --- /dev/null +++ b/packages/animated-text/package.json @@ -0,0 +1,45 @@ +{ + "name": "@react-awesome/animated-text", + "version": "0.0.0", + "main": "./dist/index.cjs", + "module": "./dist/index.js", + "types": "./dist/index.d.ts", + "sideEffects": false, + "license": "MIT", + "description": "The customizable animated text component.", + "keywords": [ + "react", + "animation", + "typewriter", + "shine", + "text", + "React", + "animated" + ], + "repository": { + "url": "https://github.com/trinhthinh388/react-awesome-components" + }, + "files": [ + "dist/**" + ], + "scripts": { + "build": "vite --config ../../vite.config.ts build", + "dev": "vite --watch --config ../../vite.config.ts build", + "lint": "eslint \"src/**/*.ts*\"", + "clean": "rimraf .turbo && rimraf node_modules && rimraf dist", + "test:ui": "vitest --config ../../vite.config.ts --coverage --ui", + "typecheck": "tsc --noEmit" + }, + "devDependencies": { + "@react-awesome/eslint-config": "*", + "@react-awesome/tsconfig": "*", + "@types/react": "^18.2.46", + "@types/react-dom": "^18.2.18", + "eslint": "^8.56.0", + "react": "^18.2.0", + "typescript": "^5.3.3" + }, + "publishConfig": { + "access": "public" + } +} diff --git a/packages/animated-text/src/AnimatedText/AnimatedText.tsx b/packages/animated-text/src/AnimatedText/AnimatedText.tsx new file mode 100644 index 0000000..01479d3 --- /dev/null +++ b/packages/animated-text/src/AnimatedText/AnimatedText.tsx @@ -0,0 +1,19 @@ +export type AnimatedTextProps = { + /** + * @description AnimatedText html tag to render + * @default p + * @requires false + */ + as?: Tag + + children?: React.ReactNode + type?: 'typewriter' +} & Omit + +export const AnimatedText: React.FC = ({ + as: Element = 'p', + children, + type = 'typewriter', +}) => { + return {children} +} diff --git a/packages/animated-text/src/TypeWriter/TypeWriter.tsx b/packages/animated-text/src/TypeWriter/TypeWriter.tsx new file mode 100644 index 0000000..917dc58 --- /dev/null +++ b/packages/animated-text/src/TypeWriter/TypeWriter.tsx @@ -0,0 +1,15 @@ +export type TypeWriterSequenceObj = { + duration: number +} + +export type TypeWriterAnimatedTextProps< + Tag extends keyof JSX.IntrinsicElements = 'p', +> = { + /** + * @description AnimatedText html tag to render + * @default p + * @requires false + */ + as?: Tag + sequences?: (string | TypeWriterSequenceObj)[] +} & JSX.IntrinsicElements[Tag] diff --git a/packages/animated-text/src/index.ts b/packages/animated-text/src/index.ts new file mode 100644 index 0000000..45ae4b3 --- /dev/null +++ b/packages/animated-text/src/index.ts @@ -0,0 +1 @@ +export * from './AnimatedText/AnimatedText' diff --git a/packages/animated-text/tsconfig.json b/packages/animated-text/tsconfig.json new file mode 100644 index 0000000..a09969e --- /dev/null +++ b/packages/animated-text/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "@react-awesome/tsconfig/react-library.json", + "compilerOptions": { + "types": ["vitest/globals"], + }, + "include": ["."], + "exclude": ["dist", "build", "node_modules"], +} diff --git a/packages/components/package.json b/packages/components/package.json index b17d8ed..af82d59 100644 --- a/packages/components/package.json +++ b/packages/components/package.json @@ -45,6 +45,7 @@ "@react-awesome/use-selection-range": "0.0.3", "@react-awesome/use-previous": "0.0.3", "@react-awesome/use-toggle": "0.0.1", - "@react-awesome/use-breakpoint": "0.0.2" + "@react-awesome/use-breakpoint": "0.0.2", + "@react-awesome/animated-text": "0.0.0" } } diff --git a/packages/components/src/index.ts b/packages/components/src/index.ts index f823fcd..022827c 100644 --- a/packages/components/src/index.ts +++ b/packages/components/src/index.ts @@ -1,4 +1,5 @@ export * from '@react-awesome/phone-input' +export * from '@react-awesome/animated-text' /** * Hooks diff --git a/vite.config.ts b/vite.config.ts index d7f5d18..6cb1ea1 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -36,6 +36,7 @@ export default defineConfig({ '@react-awesome/phone-input', '@react-awesome/use-toggle', '@react-awesome/use-breakpoint', + '@react-awesome/animated-text', ], output: [ {