Skip to content

Commit

Permalink
Halloween colors (#3)
Browse files Browse the repository at this point in the history
* add halloween version

Add Halloween version of Fart.css library.

* trigger halloween version on url search param

* run `deno fmt`

* define halloween colors
  • Loading branch information
EthanThatOneKid authored Oct 25, 2024
1 parent 76e4a19 commit 72fd299
Show file tree
Hide file tree
Showing 9 changed files with 344 additions and 275 deletions.
10 changes: 5 additions & 5 deletions fart.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@import "fonts.css";
@import "root.css";
@import "keyframes.css";
@import "misc.css";
@import "semantics.css";
@import "fonts.css";
@import "root.css";
@import "keyframes.css";
@import "misc.css";
@import "semantics.css";
2 changes: 1 addition & 1 deletion fonts.css
Original file line number Diff line number Diff line change
@@ -1 +1 @@
@import url("https://fonts.googleapis.com/css2?family=Overpass:ital,wght@0,100..900;1,100..900&display=swap");
@import url("https://fonts.googleapis.com/css2?family=Overpass:ital,wght@0,100..900;1,100..900&display=swap");
21 changes: 21 additions & 0 deletions halloween.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
:root {
--fart-purple: #800080;
--fart-dark-purple: #660066;
--fart-lighter-dark-purple: #8f008f;
--fart-darker-dark-purple: #550055;

--fart-orange: #ff7f00;
--fart-orange-transparent: #ff7f0055;

/* Overwrite the green colors with purple. */
--fart-dark-green: var(--fart-dark-purple);
--fart-lighter-dark-green: var(--fart-lighter-dark-purple);
--fart-darker-dark-green: var(--fart-darker-dark-purple);

/* Overwrite the pink colors with orange. */
--fart-pink: var(--fart-orange);
--fart-pink-transparent: var(--fart-orange-transparent);

/* Overwrite the sparkle text with a spooky sparkle. */
--fart-sparkle-text: "🦇";
}
23 changes: 23 additions & 0 deletions halloween.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* checkHalloweenWeek checks if the date is within the week of Halloween.
*/
export function checkHalloweenWeek(date: Date = new Date()): boolean {
const month = date.getMonth();
const day = date.getDate();
return month === 9 && day >= 25 && day <= 31;
}

/**
* appendHalloweenCSS appends an import to the Halloween version file if it's
* the week of Halloween.
*/
export function appendHalloweenCSS(
css: string,
isHalloweenWeek: boolean = checkHalloweenWeek(),
): string {
if (isHalloweenWeek) {
return css + `@import "halloween.css"\n`;
}

return css;
}
60 changes: 35 additions & 25 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ <h1 id="top" class="fart-header">fart.css</h1>
class="fart-button"
href="https://github.com/FartLabs/fart.css"
target="_blank"
>&bigstar;Source<small></small></a
>
>&bigstar;Source<small></small></a>
</nav>

<p>
Expand Down Expand Up @@ -96,7 +95,9 @@ <h2 id="getting-started">Getting started</h2>
To get started with fart.css, include the following line in the
<code>&lt;head&gt;</code> of your HTML file:
</p>
<pre><code>&lt;link rel="stylesheet" type="text/css" href="https://css.fart.tools" /&gt;</code></pre>
<pre
><code>&lt;link rel="stylesheet" type="text/css" href="https://css.fart.tools" /&gt;</code></pre
>
<p>
From there, you can use the classes and styles provided by the fart.css
CSS library.
Expand All @@ -110,7 +111,9 @@ <h2 id="variables">Variables</h2>
<code>var(--css-variable)</code> for colors:
</p>
<p>Colors are defined in the <a href="root.css">root.css</a> file.</p>
<pre><code>:root {
<pre
>
<code>:root {
--fart-green: </code><code style="font-weight: bold; color: var(--fart-green);">#c3ef3c</code><code>;
--fart-dark-green: </code><code style="font-weight: bold; background-color: var(--fart-off-white); color: var(--fart-dark-green);">#004021</code><code>;
--fart-darker-dark-green: </code><code style="font-weight: bold; background-color: var(--fart-off-white); color: var(--fart-darker-dark-green);">#002d17</code><code>;
Expand All @@ -121,7 +124,8 @@ <h2 id="variables">Variables</h2>

--fart-white: </code><code style="font-weight: bold; color: var(--fart-white);">#ddd</code><code>;
--fart-off-white: </code><code style="font-weight: bold; color: var(--fart-off-white);">#aaa</code><code>;
}</code></pre>
}</code></pre
>
</section>

<section class="fart-section">
Expand All @@ -148,13 +152,16 @@ <h2 id="semantics">Semantics</h2>
the <a href="semantics.css">semantics.css</a> file.
</p>
<p>Body and HTML elements are styled with:</p>
<pre><code>html,
<pre
>
<code>html,
body {
background-color: var(--fart-dark-green);
color: var(--fart-white);
font-family: sans-serif;
margin: 0;
}</code></pre>
}</code></pre
>

<p>
Check out the available styles in the
Expand Down Expand Up @@ -187,8 +194,7 @@ <h3 id="links">Links</h3>
</li>
<li>
<a class="fart-link-visible-on-hover" href="#links"
>Example .fart-link-visible-on-hover</a
>
>Example .fart-link-visible-on-hover</a>
</li>
</ul>

Expand Down Expand Up @@ -269,24 +275,24 @@ <h3 id="fart-logo">Hoverable logos</h3>
class="fart-logo"
href="#fart-logo"
style="font-size: 24pt; cursor: pointer"
>🧪</span
>
>🧪</span>
</section>

<section class="fart-section">
<h2 id="bottom">You made it to the bottom!</h2>
<p>
Thanks for checking out fart.css! If you have any questions or feedback,
<a class="fart-button" href="https://go.fart.tools/chat" target="_blank"
>Chat<small></small></a
>
<a
class="fart-button"
href="https://go.fart.tools/chat"
target="_blank"
>Chat<small></small></a>
with the community on Discord and check out our
<a
class="fart-button"
href="https://github.com/FartLabs/fart.css"
target="_blank"
>&bigstar;Source<small></small></a
>
>&bigstar;Source<small></small></a>
on GitHub! <a class="fart-button" href="#top">Top<small></small></a>
</p>
</section>
Expand All @@ -295,19 +301,23 @@ <h2 id="bottom">You made it to the bottom!</h2>

<footer>
<p>
© FartLabs <a class="fart-logo" href="https://fart.tools">🧪</a><br />
<a class="fart-button" href="https://fart.tools/blog" target="_blank"
>Blog<small></small></a
>
© FartLabs <a class="fart-logo" href="https://fart.tools">🧪</a>
<br />
<a
class="fart-button"
href="https://fart.tools/blog"
target="_blank"
>Blog<small></small></a>
<a
class="fart-button"
href="https://github.com/FartLabs"
target="_blank"
>GitHub<small></small></a
>
<a class="fart-button" href="https://go.fart.tools/chat" target="_blank"
>Chat<small></small></a
>
>GitHub<small></small></a>
<a
class="fart-button"
href="https://go.fart.tools/chat"
target="_blank"
>Chat<small></small></a>
</p>
</footer>
</body>
Expand Down
19 changes: 16 additions & 3 deletions main.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
import { serveDir, serveFile } from "@std/http";
import { serveDir } from "@std/http";
import { appendHalloweenCSS, checkHalloweenWeek } from "./halloween.ts";

Deno.serve(async (request) => {
const url = new URL(request.url);
if (
url.pathname === "/" &&
(url.pathname === "/" ||
url.pathname === "/fart.css") &&
request.headers.get("Accept")?.includes("text/css")
) {
return await serveFile(request, "fart.css");
const fartCSS = appendHalloweenCSS(
await Deno.readTextFile("fart.css"),
checkHalloweenWeek() || url.searchParams.has("halloween"),
);
return new Response(
fartCSS,
{
headers: new Headers({
"Content-Type": "text/css",
}),
},
);
}

return await serveDir(request);
Expand Down
148 changes: 74 additions & 74 deletions misc.css
Original file line number Diff line number Diff line change
@@ -1,74 +1,74 @@
.fart-section {
max-width: 64ch;
word-wrap: break-word;
margin: 6rem auto;

@media (max-width: 800px) {
padding: 0 1rem;
}
}

.fart-header {
font-family: "Overpass", sans-serif;
font-size: 1.5rem;
font-weight: 700;
}

.fart-inline {
display: grid;
grid-template-rows: 1fr;
grid-auto-flow: column;
gap: 2px;
}

.fart-button {
background-color: var(--fart-darker-dark-green);
color: var(--fart-green);
border: 1px solid var(--fart-green);
border-radius: 5px;
padding: 0.25rem 0.5rem;
text-decoration: none;
transition: background-color 0.3s;
}

.fart-button:hover {
background-color: var(--fart-lighter-dark-green);
text-decoration: underline;
}

.fart-topics {
margin-top: auto;
}

.fart-topic {
word-break: keep-all;
padding: 0.25rem 0.5rem;
border-radius: 5px;
background-color: var(--fart-lighter-dark-green);
color: var(--fart-green);
border-radius: 2rem;
display: inline-block;
margin: 2px;
}

.fart-logo {
position: absolute;
text-decoration: none;
}

.fart-logo:hover {
animation: fart-shake 560ms ease-in-out;
}

.fart-sparkle::before,
.fart-sparkle::after {
content: "✨";
}

.fart-sparkle-before::before {
content: "✨";
}

.fart-sparkle-after:after {
content: "✨";
}
.fart-section {
max-width: 64ch;
word-wrap: break-word;
margin: 6rem auto;

@media (max-width: 800px) {
padding: 0 1rem;
}
}

.fart-header {
font-family: "Overpass", sans-serif;
font-size: 1.5rem;
font-weight: 700;
}

.fart-inline {
display: grid;
grid-template-rows: 1fr;
grid-auto-flow: column;
gap: 2px;
}

.fart-button {
background-color: var(--fart-darker-dark-green);
color: var(--fart-green);
border: 1px solid var(--fart-green);
border-radius: 5px;
padding: 0.25rem 0.5rem;
text-decoration: none;
transition: background-color 0.3s;
}

.fart-button:hover {
background-color: var(--fart-lighter-dark-green);
text-decoration: underline;
}

.fart-topics {
margin-top: auto;
}

.fart-topic {
word-break: keep-all;
padding: 0.25rem 0.5rem;
border-radius: 5px;
background-color: var(--fart-lighter-dark-green);
color: var(--fart-green);
border-radius: 2rem;
display: inline-block;
margin: 2px;
}

.fart-logo {
position: absolute;
text-decoration: none;
}

.fart-logo:hover {
animation: fart-shake 560ms ease-in-out;
}

.fart-sparkle::before,
.fart-sparkle::after {
content: var(--fart-sparkle-text);
}

.fart-sparkle-before::before {
content: var(--fart-sparkle-text);
}

.fart-sparkle-after:after {
content: var(--fart-sparkle-text);
}
24 changes: 13 additions & 11 deletions root.css
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
:root {
--fart-green: #c3ef3c;
--fart-dark-green: #004021;
--fart-lighter-dark-green: #005b31;
--fart-darker-dark-green: #002d17;

--fart-pink: #db7093;
--fart-pink-transparent: #db709384;
--fart-white: #ddd;
--fart-off-white: #aaa;
}
:root {
--fart-green: #c3ef3c;
--fart-dark-green: #004021;
--fart-lighter-dark-green: #005b31;
--fart-darker-dark-green: #002d17;

--fart-pink: #db7093;
--fart-pink-transparent: #db709384;
--fart-white: #ddd;
--fart-off-white: #aaa;

--fart-sparkle-text: "✨";
}
Loading

0 comments on commit 72fd299

Please sign in to comment.