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: data-driven and random AnimatedLogo #268

Merged
merged 4 commits into from
Apr 3, 2024

Conversation

mxdvl
Copy link
Contributor

@mxdvl mxdvl commented Mar 12, 2024

Why?

By extracting the logo as an ASCII drawing, and mapping over the values, we get more control
over the shape, colours, animation randomness and positioning of the internal elements.

  ███████
  █░█░░░█████
███░█░███░░░█
█░█░█░░░█░█░█
█░░░███░█░███
█████░░░█░█
    ███████

What?

Iterate over the ASCII representation of the logo, transforming and blocks into their respective colours and discarding spaces to generate the individual SVG rect.

The SVG asset is a snapshot of the rendered HTML on a given page. Manual adjustments of individual blocks is easier with inline styles.

Copy link
Contributor

@josh-collinsworth josh-collinsworth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really, really cool. Awesome work! I love it. @lucacasonato any issues with merging this?

mxdvl added 2 commits March 30, 2024 23:43
by extracting the logo as an ASCII drawing,
and mapping over the values, we get more control
over the shape, colours, animation randomness
and positioning of the internal elements.

the asset is a snapshot of the rendered HTML
on a given page. Manual adjustments of individual
blocks is easier with inline styles.
unlike the logo on the home page which has two,
this asset has a single block of blank space.
@mxdvl mxdvl force-pushed the mxdvl/animated-logo branch from ee24286 to 6d3f95f Compare March 30, 2024 23:43
xmlnsXlink="http://www.w3.org/1999/xlink"
xml:space="preserve"
style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;"
viewBox="-2 -2 17 11"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The actual drawing is 13 by 7, but accounting for a padding of 2 all around.

We could write this thusly with less magic numbers:

const padding = 2;
const width = 13;
const height = 7;
const viewBox = [
  -padding,
  -padding,
  padding + width + padding,
  padding + height + padding,
].join(' ');

@lucacasonato
Copy link
Member

Cool. I pushed a change that fixes a little glitch I saw where the server render and the client rendered random positions would not be in sync, causing a little jump of all the pixels immediately after page load (as soon as the logo re-rendered on the client).

Fixed this by not re-rendering the logo on the client.

Also updated the CSS to respect the prefers-reduced-motion user preference.

@lucacasonato lucacasonato changed the title A data-driven & random AnimatedLogo feat: data-driven and random AnimatedLogo Apr 3, 2024
@lucacasonato lucacasonato added this pull request to the merge queue Apr 3, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Apr 3, 2024
@lucacasonato lucacasonato added this pull request to the merge queue Apr 3, 2024
Merged via the queue into jsr-io:main with commit db3f97f Apr 3, 2024
6 checks passed
@mxdvl mxdvl deleted the mxdvl/animated-logo branch April 3, 2024 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants