├── src ├── vite-env.d.ts ├── components │ ├── index.ts │ ├── Option.tsx │ └── Output.tsx ├── main.tsx ├── index.css ├── favicon.svg └── App.tsx ├── .gitignore ├── postcss.config.js ├── vite.config.ts ├── README.md ├── tailwind.config.js ├── tsconfig.json ├── package.json ├── LICENSE ├── index.html └── yarn.lock /src/vite-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .DS_Store 3 | dist 4 | dist-ssr 5 | *.local 6 | .dccache 7 | -------------------------------------------------------------------------------- /postcss.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: { 3 | tailwindcss: {}, 4 | autoprefixer: {}, 5 | }, 6 | } 7 | -------------------------------------------------------------------------------- /src/components/index.ts: -------------------------------------------------------------------------------- 1 | export { default as Output } from './Output'; 2 | export { default as Option } from './Option'; 3 | -------------------------------------------------------------------------------- /vite.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vite' 2 | import react from '@vitejs/plugin-react' 3 | 4 | // https://vitejs.dev/config/ 5 | export default defineConfig({ 6 | plugins: [react()] 7 | }) 8 | -------------------------------------------------------------------------------- /src/main.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import ReactDOM from 'react-dom' 3 | import './index.css' 4 | import App from './App' 5 | 6 | ReactDOM.render( 7 | 8 | 9 | , 10 | document.getElementById('root') 11 | ) 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Generate CSS Text Portraits with Ease! [![Mentioned in Awesome CSS Text Portrait](https://awesome.re/mentioned-badge-flat.svg)](https://github.com/warengonzaga/awesome-css-text-portrait) 2 | 3 | 4 | ![text-portrait-generator](https://user-images.githubusercontent.com/69457996/142845888-7aab4783-7e13-4ae3-af52-b4eb3f3ecbd2.jpg) 5 | -------------------------------------------------------------------------------- /tailwind.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | mode: "jit", 3 | purge: ["./src/**/*.tsx"], 4 | darkMode: false, // or 'media' or 'class' 5 | theme: { 6 | extend: { 7 | colors: { 8 | primary: "#5460E6", 9 | secondary: "#2F3136" 10 | } 11 | }, 12 | }, 13 | variants: { 14 | extend: {}, 15 | }, 16 | plugins: [], 17 | } 18 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ESNext", 4 | "useDefineForClassFields": true, 5 | "lib": ["DOM", "DOM.Iterable", "ESNext"], 6 | "allowJs": false, 7 | "skipLibCheck": false, 8 | "esModuleInterop": false, 9 | "allowSyntheticDefaultImports": true, 10 | "strict": true, 11 | "forceConsistentCasingInFileNames": true, 12 | "module": "ESNext", 13 | "moduleResolution": "Node", 14 | "resolveJsonModule": true, 15 | "isolatedModules": true, 16 | "noEmit": true, 17 | "jsx": "react-jsx" 18 | }, 19 | "include": ["./src"] 20 | } 21 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "text-art", 3 | "version": "0.0.0", 4 | "scripts": { 5 | "dev": "vite", 6 | "build": "tsc && vite build", 7 | "serve": "vite preview" 8 | }, 9 | "dependencies": { 10 | "react": "^17.0.0", 11 | "react-dom": "^17.0.0", 12 | "react-icons": "^4.3.1" 13 | }, 14 | "devDependencies": { 15 | "@types/react": "^17.0.0", 16 | "@types/react-dom": "^17.0.0", 17 | "@vitejs/plugin-react": "^1.0.0", 18 | "autoprefixer": "^10.4.0", 19 | "postcss": "^8.3.11", 20 | "tailwindcss": "^2.2.19", 21 | "typescript": "^4.3.2", 22 | "vite": "^2.6.4" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/components/Option.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | interface OptionProps { 4 | setOption: React.Dispatch>; 5 | value: number; 6 | label: string; 7 | } 8 | 9 | const Option: React.FC = ({ setOption, value, label }) => { 10 | return ( 11 |
12 |

13 | {label}: {value} 14 |

15 | 16 | setOption(Number(e.target.value))} 19 | type='range' 20 | value={value} 21 | min={1} 22 | max={100} 23 | /> 24 |
25 | ); 26 | }; 27 | 28 | export default Option; 29 | -------------------------------------------------------------------------------- /src/index.css: -------------------------------------------------------------------------------- 1 | @import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600&display=swap'); 2 | 3 | @tailwind base; 4 | @tailwind components; 5 | @tailwind utilities; 6 | 7 | body { 8 | background: #202225; 9 | font-family: 'Poppins', sans-serif; 10 | } 11 | 12 | html { 13 | overflow: scroll; 14 | overflow-x: hidden; 15 | } 16 | ::-webkit-scrollbar { 17 | width: 0; /* Remove scrollbar space */ 18 | background: transparent; /* Optional: just make scrollbar invisible */ 19 | } 20 | 21 | @layer components { 22 | .btn { 23 | @apply flex items-center space-x-2 justify-center py-2 w-full rounded transition-all; 24 | } 25 | 26 | .primary-bg { 27 | @apply bg-primary hover:bg-primary/90 hover:shadow-lg; 28 | } 29 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Josh Daniel 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/favicon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/components/Output.tsx: -------------------------------------------------------------------------------- 1 | import React, { useMemo } from 'react'; 2 | import { OutputProps } from '../App'; 3 | 4 | const Output: React.FC = ({ 5 | file, 6 | textBg, 7 | fontSize, 8 | lineHeight, 9 | grayscale, 10 | multiplyText, 11 | showFull, 12 | }) => { 13 | const photoUrl = useMemo(() => file && URL.createObjectURL(file), [file]); 14 | 15 | return ( 16 |
17 |

28 | {Array(showFull ? 100 : multiplyText) 29 | .fill(0) 30 | .map( 31 | () => 32 | textBg || 33 | 'Never gonna give you up Never gonna let you down Never gonna run around and desert you Never gonna make you cry Never gonna say goodbye Never gonna tell a lie and hurt you Never gonna give you up Never gonna let you down Never gonna run around and desert you Never gonna make you cry Never gonna say goodbye Never gonna give you up Never gonna let you down Never gonna run around and desert you Never gonna make you cry Never gonna say goodbye' 34 | )} 35 |

36 |
37 | ); 38 | }; 39 | 40 | export default Output; 41 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 23 | 24 | 25 | 29 | 33 | 34 | 38 | 42 | 43 | Text Portrait Generator 44 | 45 | 46 |
47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /src/App.tsx: -------------------------------------------------------------------------------- 1 | import React, { useState, useRef } from 'react'; 2 | import { Output, Option } from './components'; 3 | import { MdFilter, MdRestartAlt } from 'react-icons/md'; 4 | import { BsImageFill, BsEyeFill, BsStarFill } from 'react-icons/bs'; 5 | 6 | export interface OutputProps { 7 | file: File | null; 8 | textBg: string; 9 | fontSize: number; 10 | lineHeight: number; 11 | grayscale: boolean; 12 | multiplyText: number; 13 | showFull: boolean; 14 | } 15 | 16 | const App: React.FC = () => { 17 | const [textBg, setTextBg] = useState(''); 18 | const [fontSize, setFontSize] = useState(16); 19 | const [lineHeight, setLineHeight] = useState(10); 20 | const [multiplyText, setMultiplyText] = useState(100); 21 | 22 | const [showFull, setShowFull] = useState(false); 23 | const [grayscale, setGrayscale] = useState(false); 24 | const [file, setFile] = useState(null); 25 | 26 | const fileRef = useRef(null); 27 | 28 | const outputProps: OutputProps = { 29 | file, 30 | textBg, 31 | fontSize, 32 | lineHeight, 33 | grayscale, 34 | multiplyText, 35 | showFull, 36 | }; 37 | 38 | const resetOptions = () => { 39 | setTextBg(''); 40 | setFontSize(16); 41 | setLineHeight(10); 42 | setMultiplyText(100); 43 | setGrayscale(false); 44 | }; 45 | 46 | if (showFull) return ; 47 | 48 | return ( 49 |
50 |
51 |
52 | 58 |

Star on GitHub

59 | 60 |
61 | 62 |
63 | 70 | 71 | 80 |
81 | 82 |