Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/animated text #92

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions apps/docs/src/pages/docs/_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
"phone-input": {
"title": "PhoneInput"
},
"animated-text": {
"title": "AnimatedText"
},
"-- Hooks": {
"type": "separator",
"title": "Hooks"
Expand Down
32 changes: 32 additions & 0 deletions apps/docs/src/pages/docs/animated-text.mdx
Original file line number Diff line number Diff line change
@@ -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 <AnimatedText />
}

**AnimtedText** can support animate as `typewriter` effect.

<Container>
<TypeWritter />
</Container>
8 changes: 8 additions & 0 deletions packages/animated-text/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
root: true,
extends: ["@react-awesome/eslint-config/library.js"],
parser: "@typescript-eslint/parser",
parserOptions: {
project: true,
},
};
32 changes: 32 additions & 0 deletions packages/animated-text/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# @react-awesome/animated-text

<p align="center">
<img alt="version" src="https://img.shields.io/npm/v/%40react-awesome%2Fanimated-text" />
<img alt="coverage" src="https://img.shields.io/codecov/c/github/trinhthinh388/react-awesome-components/master?token=VQ8VJ7OECQ&flag=animated-text" />
<img alt="license" src="https://img.shields.io/github/license/trinhthinh388/react-awesome-components" />
<img alt="build status" src="https://img.shields.io/github/actions/workflow/status/trinhthinh388/react-awesome-components/release.yml" />
<img alt="size" src="https://img.shields.io/bundlejs/size/%40react-awesome/animated-text" />
</p>

**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).
45 changes: 45 additions & 0 deletions packages/animated-text/package.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
19 changes: 19 additions & 0 deletions packages/animated-text/src/AnimatedText/AnimatedText.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
export type AnimatedTextProps<Tag extends keyof JSX.IntrinsicElements = 'p'> = {

Check warning on line 1 in packages/animated-text/src/AnimatedText/AnimatedText.tsx

View workflow job for this annotation

GitHub Actions / ⬣ ESLint

Definition for rule '@typescript-eslint/no-unused-vars' was not found
/**
* @description AnimatedText html tag to render
* @default p
* @requires false
*/
as?: Tag

children?: React.ReactNode
type?: 'typewriter'
} & Omit<JSX.IntrinsicElements[Tag], 'type'>

export const AnimatedText: React.FC<AnimatedTextProps> = ({
as: Element = 'p',
children,
type = 'typewriter',
}) => {
return <Element>{children}</Element>
}
15 changes: 15 additions & 0 deletions packages/animated-text/src/TypeWriter/TypeWriter.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export type TypeWriterSequenceObj = {

Check warning on line 1 in packages/animated-text/src/TypeWriter/TypeWriter.tsx

View workflow job for this annotation

GitHub Actions / ⬣ ESLint

Definition for rule '@typescript-eslint/no-unused-vars' was not found
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]
1 change: 1 addition & 0 deletions packages/animated-text/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './AnimatedText/AnimatedText'

Check warning on line 1 in packages/animated-text/src/index.ts

View workflow job for this annotation

GitHub Actions / ⬣ ESLint

Definition for rule '@typescript-eslint/no-unused-vars' was not found
8 changes: 8 additions & 0 deletions packages/animated-text/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "@react-awesome/tsconfig/react-library.json",
"compilerOptions": {
"types": ["vitest/globals"],
},
"include": ["."],
"exclude": ["dist", "build", "node_modules"],
}
3 changes: 2 additions & 1 deletion packages/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
1 change: 1 addition & 0 deletions packages/components/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export * from '@react-awesome/phone-input'

Check warning on line 1 in packages/components/src/index.ts

View workflow job for this annotation

GitHub Actions / ⬣ ESLint

Definition for rule '@typescript-eslint/no-unused-vars' was not found
export * from '@react-awesome/animated-text'

/**
* Hooks
Expand Down
1 change: 1 addition & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export default defineConfig({
'@react-awesome/phone-input',
'@react-awesome/use-toggle',
'@react-awesome/use-breakpoint',
'@react-awesome/animated-text',
],
output: [
{
Expand Down
Loading