Skip to main content
100%

smiley face refactoring into react components

✓ Published2🌍 Public
Ddmr
Last edited Nov 13, 2021
Created on Nov 13, 2021

This example displays a smiley face built from a yellow circle, two eyes, and a curved mouth, rendered as SVG. The code refactors drawing primitives into named React components like `BackgroundCircle`, `Eyes`, and `Mouth`, with `Face` orchestrating their layout and `FaceContainer` providing the SVG canvas. It uses React for component composition and d3’s `arc` function to generate the mouth’s path. Properties such as eye offset and mouth radius are passed as parameters, enabling flexible geometry without hard-coded coordinates.

AI-generated description

A bare minimum HTML page demonstrating use of CSS and JavaScript.

See also React Starter.

extra notes

Smiley face part 1 uses svg to create the face and two eyes but we need to be able to use some math to set items out without hard coding all the x and y offsets

so it's time for REACT

In this fork:

  • refactor the drawing elements like circle into React components with meaningful names
MIT Licensed

Similar vizzes