Skip to main content
100%

Making a Clock

✓ Published0🌍 Public
Jjjacobatandover
Last edited Jul 13, 2021
Created on Jul 4, 2021

This example shows a static clock face rendered with SVG. The clock includes a circular face, hour, minute, and second hands, numeric labels, and tick marks at the 12, 3, 6, and 9 positions. Built with React and JSX, the code uses CSS for page margins and the `circle`, `line`, and `text` SVG elements to construct the layout. It positions elements using a centered `<g>` transform and rotates ticks with the SVG `transform="rotate(...)"` attribute. The D3 `arc` function is imported but not used in the final output.

AI-generated description

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

See also React Starter.

Half way towards a smiley face -- we used CSS to make the margins and the colors.

We used SVG to make the circles.

Feeling frustrated that we couldn't use math to define the DOM structure and use JSX to write HTML in JS and math from JS

Using React, we used JSX to allow us to include HTML in JS

In order to get the smile, we need to use an arc feature, but there's no such element in SVG. So we need to use D3.

We can use d3-shape to get the arc

MIT Licensed

Similar vizzes