-
Notifications
You must be signed in to change notification settings - Fork 372
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #393 from javigaralva/feature/visual-and-abstract-…
…style Feature/visual and abstract style
- Loading branch information
Showing
13 changed files
with
219 additions
and
44 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
src/components/javigaralva/components/colorized-letter.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { CSSProperties } from 'react' | ||
import { sample } from '../utils/sample' | ||
import { getVerticalLinesStyle } from '../utils/style-generators/vertical-lines' | ||
import { getSquareAndVerticalLinesStyle } from '../utils/style-generators/square-and-vertical-lines' | ||
import { getBigCircleDottedStyle } from '../utils/style-generators/big-circle-doted' | ||
import { getBigDotsStyle } from '../utils/style-generators/big-dots' | ||
import { isUpperCaseLetter } from '../utils/is-upper-case-letter' | ||
import { isSymbol } from '../utils/is-symbol' | ||
import { isNumber } from '../utils/is-number' | ||
|
||
type ColorizedLetterStyles = { | ||
classNames: string | ||
style: CSSProperties | ||
} | ||
|
||
interface ColorizedLetterProps { | ||
letter: string | ||
} | ||
export function ColorizedLetter({ letter }: ColorizedLetterProps) { | ||
const { classNames, style } = getStyles(letter) | ||
return ( | ||
<span className={classNames} style={style}> | ||
{letter} | ||
</span> | ||
) | ||
} | ||
|
||
function getStyles(letter: string): ColorizedLetterStyles { | ||
let classNames = 'text-white' | ||
let style: CSSProperties = {} | ||
if (isNumber(letter)) { | ||
classNames = 'text-orange-600' | ||
style = getBigDotsStyle() | ||
} else if (isSymbol(letter)) { | ||
classNames = 'text-lime-600' | ||
style = getBigCircleDottedStyle() | ||
style.textShadow = 'rgb(116 255 77 / 60%) -1px -1px 6px, rgb(124 127 255 / 0%) 1px 1px 6px' | ||
} else if (isUpperCaseLetter(letter)) { | ||
classNames = 'text-white/50' | ||
style = getSquareAndVerticalLinesStyle() | ||
} else { | ||
classNames = 'text-white px-4' | ||
style = getVerticalLinesStyle() | ||
} | ||
|
||
const duration = sample(['duration-500', 'duration-700', 'duration-1000']) | ||
|
||
classNames = `${duration} hover:scale-150 inline-block ${classNames}` | ||
|
||
return { | ||
classNames, | ||
style | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/components/javigaralva/components/colorized-password.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { ColorizedLetter } from './colorized-letter' | ||
|
||
interface ColorizedPasswordProps { | ||
password: string | ||
} | ||
export function ColorizedPassword({ password }: ColorizedPasswordProps) { | ||
return ( | ||
<div className='font-mono font-black text-4xl min-h-min tracking-widest cursor-pointer'> | ||
{password.split('').map((letter, i) => ( | ||
<ColorizedLetter key={i} letter={letter} /> | ||
))} | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
const LETTERS = 'abcdefghijklmnopqrstuvwxyz' | ||
export const NUMBERS = '0123456789' | ||
export const SYMBOLS = '\'\\¡!"·$%&()=€@[]{}^/+-*' | ||
export const UPPER_CASE_LETTERS_LIST = LETTERS.toUpperCase().split('') | ||
export const LOWER_CASE_LETTERS_LIST = LETTERS.toLowerCase().split('') | ||
export const NUMBERS_LIST = NUMBERS.split('') | ||
export const SYMBOLS_LIST = SYMBOLS.split('') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { NUMBERS } from '../constants/constants' | ||
|
||
export function isNumber(letter: string) { | ||
return NUMBERS.includes(letter) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { SYMBOLS } from '../constants/constants' | ||
|
||
export function isSymbol(letter: string) { | ||
return SYMBOLS.includes(letter) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { UPPER_CASE_LETTERS_LIST } from '../constants/constants' | ||
|
||
export function isUpperCaseLetter(letter: string) { | ||
return UPPER_CASE_LETTERS_LIST.includes(letter) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export function random(min: number, max: number) { | ||
return Math.floor(Math.random() * (max - min + 1) + min) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export function sample<T>(arr: T[]) { | ||
return arr[Math.floor(Math.random() * arr.length)] | ||
} |
16 changes: 16 additions & 0 deletions
16
src/components/javigaralva/utils/style-generators/big-circle-doted.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { CSSProperties } from 'react' | ||
import { random } from '../random' | ||
|
||
export function getBigCircleDottedStyle() { | ||
const style: CSSProperties = {} | ||
const width = 8 + random(-4, 2) | ||
const offset = 204 + random(-100, 100) | ||
const alpha = 6 + random(-2, 2) | ||
const color = 124 + random(-25, 75) | ||
style.outlineOffset = `${offset}px` | ||
style.outlineColor = `hsl(${color}deg 100% 50% / ${alpha}%)` | ||
style.outlineWidth = `${width}px` | ||
style.outlineStyle = 'dotted' | ||
style.borderRadius = '50%' | ||
return style | ||
} |
16 changes: 16 additions & 0 deletions
16
src/components/javigaralva/utils/style-generators/big-dots.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { CSSProperties } from 'react' | ||
import { random } from '../random' | ||
|
||
export function getBigDotsStyle() { | ||
const style: CSSProperties = {} | ||
const width = 128 + random(-100, 100) | ||
const offset = 154 + random(-100, 100) | ||
const alpha = 2 + random(-1, 6) | ||
const color = 0 + random(-10, 40) | ||
style.outlineOffset = `${offset}px` | ||
style.outlineColor = `hsl(${color}deg 100% 50% / ${alpha}%)` | ||
style.outlineWidth = `${width}px` | ||
style.outlineStyle = 'dotted' | ||
style.borderRadius = '50%' | ||
return style | ||
} |
25 changes: 25 additions & 0 deletions
25
src/components/javigaralva/utils/style-generators/square-and-vertical-lines.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { CSSProperties } from 'react' | ||
import { random } from '../random' | ||
|
||
export function getSquareAndVerticalLinesStyle() { | ||
const style: CSSProperties = {} | ||
{ | ||
const width = 28 + random(-10, 10) | ||
const alpha = 4 + random(-2, 2) | ||
const offset = 54 + random(-50, 50) | ||
const color = 0 + random(50, 100) | ||
style.outlineOffset = `${offset}px` | ||
style.outlineColor = `hsl(${color}deg 100% 50% / ${alpha}%)` | ||
style.outlineWidth = `${width}px` | ||
style.outlineStyle = 'dashed' | ||
} | ||
{ | ||
const thickness = 380 + random(-200, 100) | ||
const alpha = 4 + random(-2, 2) | ||
const color = 0 + random(100, 150) | ||
style.textDecorationLine = 'underline' | ||
style.textDecorationColor = `hsl(${color}deg 100% 50% / ${alpha}%)` | ||
style.textDecorationThickness = `${thickness}px` | ||
} | ||
return style | ||
} |
13 changes: 13 additions & 0 deletions
13
src/components/javigaralva/utils/style-generators/vertical-lines.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { CSSProperties } from 'react' | ||
import { random } from '../random' | ||
|
||
export function getVerticalLinesStyle() { | ||
const style: CSSProperties = {} | ||
const thickness = 380 + random(-200, 100) | ||
const alpha = 4 + random(-2, 2) | ||
style.textDecorationLine = 'overline' | ||
const color = 0 + random(50, 100) | ||
style.textDecorationColor = `hsl(${color}deg 100% 50% / ${alpha}%)` | ||
style.textDecorationThickness = `${thickness}px` | ||
return style | ||
} |
35d3d56
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
hacktoberfest-2022 – ./
hacktoberfest-2022-git-main-midudev-pro.vercel.app
hacktoberfest-2022-midudev-pro.vercel.app
hacktoberfest-2022.vercel.app