Skip to content

Commit

Permalink
multi circle exercise
Browse files Browse the repository at this point in the history
  • Loading branch information
holtzy committed Aug 8, 2024
1 parent acd143f commit 8f4f840
Show file tree
Hide file tree
Showing 20 changed files with 32 additions and 64 deletions.
9 changes: 0 additions & 9 deletions exercise/SvgLinePractice/SvgLine.tsx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
export const SvgRectangle = () => {
return (
<svg width={500} height={300}>
<text x="50" y="50" fill="black">
Draw a rect here!
</text>
{/* Add some circles here! */}
</svg>
);
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// File used to render something in codesandbox only
import ReactDOM from 'react-dom';
import { SvgText } from './SvgText';
import { SvgMultipleCircles } from './SvgMultipleCircles';

const rootElement = document.getElementById('root');
ReactDOM.render(<SvgText />, rootElement);
ReactDOM.render(<SvgMultipleCircles />, rootElement);
File renamed without changes.
11 changes: 11 additions & 0 deletions exercise/SvgMultipleCirclesSolution/SvgMultipleCircles.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export const SvgRectangle = () => {
const numbers = [...Array(10).keys()];

return (
<svg width={500} height={300}>
{numbers.map((i) => {
return <circle key={i} cx={50 + i * 40} cy={150} r={20} fill="blue" />;
})}
</svg>
);
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// File used to render something in codesandbox only
import ReactDOM from 'react-dom';
import { SvgLine } from './SvgLine';
import { SvgMultipleCircles } from './SvgMultipleCircles';

const rootElement = document.getElementById('root');
ReactDOM.render(<SvgLine />, rootElement);
ReactDOM.render(<SvgMultipleCircles />, rootElement);
File renamed without changes.
6 changes: 0 additions & 6 deletions exercise/SvgRectangleSolution/index.js

This file was deleted.

3 changes: 0 additions & 3 deletions exercise/SvgTextPractice/SvgText.tsx

This file was deleted.

28 changes: 0 additions & 28 deletions exercise/SvgTextSolution/package.json

This file was deleted.

27 changes: 16 additions & 11 deletions pages/course/svg/main-svg-elements.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { CodeSandbox } from '@/component/CodeSandbox';
import { CodeBlock } from '@/component/UI/CodeBlock';
import { ExerciseAccordion } from '@/component/ExerciseAccordion';
import Link from 'next/link';
import { Badge } from '@/component/UI/badge';

const previousURL = '/course/svg/introduction';
const currentURL = '/course/svg/main-svg-elements';
Expand Down Expand Up @@ -35,12 +34,13 @@ export default function Home() {
description={
<>
<p>
In the previous lesson we learnt what SVG is and how to draw a
In the previous lesson, we learned about SVG and how to draw a
circle with it.
</p>
<p>
We'll need other shapes to make graphs: rectangle, text, segment.
Let's see how to make them too.
To create comprehensive graphs, we'll also need{' '}
<b>other shapes</b> such as rectangles, text, and lines. Let's
explore how to create these as well.
</p>
</>
}
Expand Down Expand Up @@ -123,10 +123,14 @@ export default function Home() {

<h2>Circle</h2>
<p>
SVG circles are created using the <code>&lt;circle&gt;</code> element,
which requires the center coordinates and radius as attributes. The{' '}
<code>cx</code> and <code>cy</code> attributes specify the center point,
while the <code>r</code> attribute determines the radius of the circle.
We talked about them already, but remember that SVG circles are created
using the <code>&lt;circle&gt;</code> element, which requires the{' '}
<b>center coordinates</b> and <b>radius</b> as attributes.
</p>
<p>
The <code>cx</code> and <code>cy</code> attributes specify the center
point, while the <code>r</code> attribute determines the radius of the
circle.
</p>
<p>
For example, this code will draw a red circle with a center at (50,50)
Expand All @@ -150,7 +154,8 @@ export default function Home() {
exercises={[
{
title: <span>Draw 2 circles</span>,
description: <p>Do this and this mate</p>,
whyItMatters: <p>Do this and this mate</p>,
toDo: <p>Do this</p>,
practiceSandbox: 'SvgCircle',
solutionSandbox: 'SvgRectangle',
},
Expand Down Expand Up @@ -181,8 +186,8 @@ export default function Home() {
<li>Change the circle position at each iteration</li>
</ul>
),
practiceSandbox: 'SvgCircle',
solutionSandbox: 'SvgRectangle',
practiceSandbox: 'SvgMultipleCirclesPractice',
solutionSandbox: 'SvgMultipleCirclesSolution',
},
]}
/>
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 8f4f840

Please sign in to comment.