Skip to content

Commit

Permalink
chore: add editable content, size variation.
Browse files Browse the repository at this point in the history
  • Loading branch information
printerscanner committed Nov 3, 2023
1 parent 00b783f commit c10eb53
Show file tree
Hide file tree
Showing 7 changed files with 212 additions and 12 deletions.
20 changes: 12 additions & 8 deletions src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
import data from './data/api.js'
import EditableContent from './EditableContent'

function App() {
let productIds = Object.keys(data);
return (
<div>
{productIds.map((id) => (
<a

<div key={id}>
<EditableContent
title={data[id].title}
fontFamily={data[id].fontFamily}
/>
<a
href={data[id].link ? `${data[id].link}` : `work/${id}`}
key={id}

>
<>
{data[id].thumbnail && !data[id].mov && <img loading="lazy" src={data[id].thumbnail} alt={data[id].title} />}
{data[id].mov && <video loading="lazy" autoPlay={true} muted={true}><source autoPlay src={data[id].mov} type="video/mp4" /></video>}
<div className="text item">
<p>{data[id].link ? <span></span> : ''} <b>{data[id].title}</b></p>
<p style={{fontSize: '12px', paddingBottom: '.5rem'}}>{data[id].subcategory ? <span className="grid-crumbs">{data[id].subcategory}</span> : ''}
{data[id].category ? <span className="grid-crumbs">{data[id].category}</span> : ''}
<p style={{fontSize: '12px', paddingBottom: '.5rem'}}>
{data[id].year ? <span className="grid-crumbs">{data[id].year}</span> : ''} </p>
<p>{data[id].description}</p>
</div>
</>
</a>
</a>
</div>
))}
</div>
);
Expand Down
48 changes: 48 additions & 0 deletions src/EditableContent.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/* eslint-disable react/prop-types */
import { useState } from 'react';
import sampleTexts from './sampleTexts';

function EditableContent(props) {
const [fontSize, setFontSize] = useState(75);
const [content, setContent] = useState(props.fontFamily);

const getRandomSampleText = () => {
const randomIndex = Math.floor(Math.random() * sampleTexts.length);
return sampleTexts[randomIndex];
};

const handleRefreshClick = () => {
setFontSize(58);
setContent(getRandomSampleText());
};

return (
<div className='editableContentWrapper'>
<div className='editableRow'>
<h2>{props.title}</h2>
<div className='flex'>
<input
type="range"
min="16"
max="150"
value={fontSize}
onChange={(e) => setFontSize(e.target.value)}
/>
<button onClick={handleRefreshClick} className="refresh-button">&#8635;</button>
</div>
</div>
<div
className='editableContent'
contentEditable={true}
spellCheck={false}
style={{
fontFamily: props.fontFamily,
fontSize: `${fontSize}px`,
}}
dangerouslySetInnerHTML={{ __html: content }}
></div>
</div>
);
}

export default EditableContent;
Binary file not shown.
Binary file not shown.
5 changes: 2 additions & 3 deletions src/data/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@
const data = {
"coaster-sans": {
title: "Coaster Sans",
category: "with Mother",
featured: true,
fontFamily: "Coaster Sans",
year: '2023',
description: "A new chunky display font that will make you feel like you're riding the waves back home.",
content: "There's still some proofing on this font being done, so if you like it, give me a buzz at <a href='mailto:[email protected]'>[email protected]</a> and I'll let you know when v1.1 is out.",
downloadLink: 'https://printerscanner.net/CoasterSans.zip'
},
"body-sans": {
title: "(my) body sans",
category: "with Mother",
fontFamily: "Body Sans",
description: "You've seen kitsch body fonts, but you haven't seen one that's literally my body. Great for resumes and businesses. If you are a corporation, please reach out directly regarding a business license.",
year: '2023',
downloadLink: 'https://printerscanner.net/BodySans-Regular.zip'
Expand Down
104 changes: 103 additions & 1 deletion src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@
font-weight: 700;
}

@font-face {
font-family: 'Coaster Sans';
src: url("assets/downloadable-fonts/CoasterSans-Regular.woff") format("woff");
}

@font-face {
font-family: 'Body Sans';
src: url("assets/downloadable-fonts/BodySans-Regular.woff") format("woff");
}

:root {
--background-color: #ffffff;
--text-color: #000000;
Expand Down Expand Up @@ -36,12 +46,104 @@ body {
a {
text-decoration: none;
color: var(--text-color);
border-bottom: 1px dashed var(--text-color); /* Add a dashed underline on links */
}

.logo {
font-size: xxx-large;
}

.flex {
display: flex;
}

.item {
border-bottom: 1px solid var(--text-color);
}
}

.editableContentWrapper {
position: relative;
display: flex;
flex-direction: column;
}

.editableRow {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
}

.editableContent {
display: block;
font-size: 100px;
outline: 0;
max-width: 100vw;
padding: 20px;
background-color: white; /* Set the default background color to white */
transition: background-color 0.3s; /* Add a smooth transition effect */
}

.editableContent:focus,
.editableContent:hover {
background-color: lightgray; /* Change the background color when focused */
}

/* Add this CSS to your stylesheet */
.refresh-button {
background-color: black; /* Background color for the button */
color: #fff; /* Text color */
border: none;
margin: 10px;
padding: 10px 15px;
border-radius: 5px;
cursor: pointer;
font-size: 16px;
display: flex;
align-items: center;
justify-content: center;
}

.refresh-button:hover {
background-color: #0056b3; /* Background color on hover */
}


/* Slider Styles */
input[type="range"] {
-webkit-appearance: none;
width: 100%;
background: linear-gradient(to right, #000, #fff); /* Black and white gradient background */
border: 1px solid gray;
outline: none;
opacity: 0.7;
-webkit-transition: .2s;
transition: opacity .2s;
}

input[type="range"]:hover {
opacity: 1;
}

/* Track Styles */
input[type="range"]::-webkit-slider-runnable-track {
width: 100%;
cursor: pointer;
background: transparent; /* Make the track transparent */
border: 1px solid #fff; /* White border */
border-radius: 5px;
}

/* Thumb Styles */
input[type="range"]::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
width: 20px;
height: 20px;
cursor: pointer;
background: #000; /* Black thumb */
border: 2px solid #fff; /* White border */
border-radius: 50%;
margin-top: -5px; /* Center the thumb vertically */
}

47 changes: 47 additions & 0 deletions src/sampleTexts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
const sampleTexts = [
'I am Groot.',
'To infinity and beyond!',
'May the Force be with you.',
'Here’s Johnny!',
'Hasta la vista, baby.',
'Keep your friends close, but your enemies closer.',
'You can’t handle the truth!',
'The only thing we have to fear is fear itself.',
'Life is like a box of chocolates.',
'I feel the need... the need for speed.',
'I see dead people.',
'I’ll be back.',
'You talking to me?',
'It’s alive! It’s alive!',
'Bond. James Bond.',
'I’m the king of the world!',
'I’ll have what she’s having.',
'Here’s looking at you, kid.',
'You shall not pass!',
'Houston, we have a problem.',
'This is the way.',
'I love the smell of napalm in the morning.',
'I’ll be there for you.',
'Shaken, not stirred.',
'I have the high ground.',
'I’ve got a bad feeling about this.',
'Live long and prosper.',
'Do or do not. There is no try.',
'I have a bad feeling about this.',
'You’re a wizard, Harry.',
'Why so serious?',
'Use the Force, Luke.',
'Go ahead, make my day.',
'I am your father.',
'I can’t carry it for you, but I can carry you.',
'The power of the Force. Inside you.',
'No, I am your father.',
'I don’t want to survive. I want to live.',
'The Force will be with you. Always.',
'Once upon a time in a land far, far away, there lived a young hero who was destined to save the kingdom. This hero, armed with a magical sword, embarked on a perilous journey filled with monsters, wizards, and treacherous obstacles. Along the way, the hero met loyal companions, faced moral dilemmas, and ultimately confronted the evil sorcerer who threatened the realm. The battle was fierce, and the heros courage shone brightly as the fate of the kingdom hung in the balance. In the end, good triumphed over evil, and the heros name was celebrated throughout the land for generations to come.',
'In a galaxy not so far away, a group of rebels fought against the tyrannical rule of an oppressive empire. Their mission: to steal the plans for the empire\'s ultimate weapon, the Death Star. As they faced insurmountable odds, the rebels showed incredible bravery and determination. With the fate of the galaxy at stake, they risked it all to bring hope to those who had none. The force of good prevailed, and the rebels actions paved the way for a new hope and a brighter future.',
'Once in a quiet town nestled among rolling hills, there lived a mysterious stranger. This stranger had a secret, a secret that would change the town forever. As the townspeople got to know the stranger, they discovered that the power of kindness and compassion could transform even the most enigmatic individuals. With each act of goodwill, the strangers true nature was revealed, and the town became a place of warmth and acceptance, where all were welcome and loved. In the end, the stranger left, but their legacy of love and understanding remained, a testament to the extraordinary power of simple acts of kindness.'
];


export default sampleTexts;

0 comments on commit c10eb53

Please sign in to comment.