Skip to content

Commit

Permalink
e
Browse files Browse the repository at this point in the history
  • Loading branch information
holtzy committed Oct 22, 2024
1 parent b8990e9 commit 0e04202
Show file tree
Hide file tree
Showing 7 changed files with 117 additions and 6 deletions.
40 changes: 34 additions & 6 deletions pages/course/svg/introduction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { ExerciseAccordion } from '@/component/ExerciseAccordion';
import { ExerciseDoubleSandbox } from '@/component/ExerciseDoubleSandbox';
import { Caption } from '@/component/UI/Caption';
import { Sidenote } from '@/component/SideNote';
import { ScatterplotBasicDemo } from '@/viz/ScatterplotBasic/ScatterplotBasicDemo';

const previousURL = '/course/introduction/initial-setup';
const currentURL = '/course/svg/introduction';
Expand Down Expand Up @@ -238,17 +239,22 @@ export default function Home() {
title: <span>Developer console</span>,
content: (
<div>
<p>Some random content mate!</p>
<p>
Open your developer console and inspect the scatterplot below.
</p>
<p>
Take some time to understand how the SVG structure is
organized.
</p>
<center>
<ScatterplotBasicDemo width={500} height={500} />
</center>
</div>
),
},
{
title: <span>Background Color</span>,
content: (
<div>
<p>Some random content mate!</p>
</div>
),
content: <ExerciseDoubleSandbox exercise={exercices[2]} />,
},
{
title: <span>Overflow</span>,
Expand Down Expand Up @@ -323,4 +329,26 @@ const exercices = [
practiceSandbox: 'exercise/SvgThreeCirclesPractice',
solutionSandbox: 'exercise/SvgThreeCirclesSolution',
},
{
title: <span>Background Color</span>,
whyItMatters: (
<>
<p>
Many CSS features either don't work or behave differently with SVG.
</p>
<p>We'll uncover them all as we go through the course!</p>
</>
),
toDo: (
<>
<p>
Add some <b>inline style</b> to the svg area below. Use the{' '}
<code>backgroundColor</code>
property to change the background to <code>yellow</code>.
</p>
</>
),
practiceSandbox: 'exercise/SvgBackgroundColorPractice',
solutionSandbox: 'exercise/SvgBackgroundColorSolution',
},
];
7 changes: 7 additions & 0 deletions viz/exercise/SvgBackgroundColorPractice/SvgDrawing.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export const SvgDrawing = () => {
return (
<svg width={500} height={300}>
<circle cx={500 / 2} cy={500 / 2} r={45} fill="blue" />
</svg>
);
};
6 changes: 6 additions & 0 deletions viz/exercise/SvgBackgroundColorPractice/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// File used to render something in codesandbox only
import ReactDOM from 'react-dom';
import { SvgDrawing } from './SvgDrawing';

const rootElement = document.getElementById('root');
ReactDOM.render(<SvgDrawing />, rootElement);
28 changes: 28 additions & 0 deletions viz/exercise/SvgBackgroundColorPractice/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "pie-chart-basic",
"version": "1.0.0",
"description": "",
"keywords": [],
"main": "index.js",
"dependencies": {
"react": "17.0.2",
"react-dom": "17.0.2",
"react-scripts": "4.0.0"
},
"devDependencies": {
"@babel/runtime": "7.13.8",
"typescript": "4.1.3"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
]
}
8 changes: 8 additions & 0 deletions viz/exercise/SvgBackgroundColorSolution/SvgDrawing.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export const SvgDrawing = () => {
return (
<svg width={500} height={300}>
<rect x={0} y={0} width={500} height={300} fill="grey" />
<circle cx={500 / 2} cy={500 / 2} r={45} fill="blue" />
</svg>
);
};
6 changes: 6 additions & 0 deletions viz/exercise/SvgBackgroundColorSolution/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// File used to render something in codesandbox only
import ReactDOM from 'react-dom';
import { SvgDrawing } from './SvgDrawing';

const rootElement = document.getElementById('root');
ReactDOM.render(<SvgDrawing />, rootElement);
28 changes: 28 additions & 0 deletions viz/exercise/SvgBackgroundColorSolution/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "pie-chart-basic",
"version": "1.0.0",
"description": "",
"keywords": [],
"main": "index.js",
"dependencies": {
"react": "17.0.2",
"react-dom": "17.0.2",
"react-scripts": "4.0.0"
},
"devDependencies": {
"@babel/runtime": "7.13.8",
"typescript": "4.1.3"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
]
}

0 comments on commit 0e04202

Please sign in to comment.