Skip to content

Commit

Permalink
k
Browse files Browse the repository at this point in the history
  • Loading branch information
holtzy committed Aug 8, 2024
1 parent 08fb277 commit e5cc78d
Show file tree
Hide file tree
Showing 8 changed files with 116 additions and 4 deletions.
5 changes: 3 additions & 2 deletions component/ExerciseAccordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
AccordionTrigger,
} from '@/component/UI/accordion';
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/component/UI/tabs';
import { Eye } from 'lucide-react';
import { Check, Eye } from 'lucide-react';
import { ReactNode } from 'react';
import { CodeSandbox } from './CodeSandbox';
import { Badge } from './UI/badge';
Expand Down Expand Up @@ -34,9 +34,10 @@ export const ExerciseAccordion = ({ exercises }: ExerciseAccordionProps) => {
<span>{i + 1}</span>
</div>
<span>{exercise.title}</span>
<Eye />
<Check size={16} />
</div>
</AccordionTrigger>

<AccordionContent>
<div className="grid grid-cols-2 gap-4 pt-4">
<div>
Expand Down
33 changes: 31 additions & 2 deletions pages/course/svg/main-svg-elements.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,37 @@ export default function Home() {
<li>Add some text in the circle</li>
</ul>
),
practiceSandbox: 'exercise/SvgMultipleCirclesPractice',
solutionSandbox: 'exercise/SvgMultipleCirclesSolution',
practiceSandbox: 'exercise/SvgStackingOrderPractice',
solutionSandbox: 'exercise/SvgStackingOrderSolution',
},

{
title: <span>Dealing with SVG overflow</span>,
whyItMatters: (
<>
<p>
Parts of the SVG elements that extend beyond the SVG canvas
boundaries will not be visible. It is called <b>clipping</b>.{' '}
</p>
<p>
But you can change the <code>overflow</code> css property of
the svg element to <code>visible</code> to show shapes outside
the SVG element boundaries.
</p>
</>
),
toDo: (
<ul>
<li>Draw a big circle at the bottom of the SVG area.</li>
<li>Notice that a part of it is clipped!</li>
<li>
Use the overflow property to avoid clipping and show the full
circle
</li>
</ul>
),
practiceSandbox: 'exercise/SvgStackingOrderPractice',
solutionSandbox: 'exercise/SvgStackingOrderSolution',
},
]}
/>
Expand Down
7 changes: 7 additions & 0 deletions viz/exercise/SvgOverflowPractice/Graph.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export const Graph = () => {
return (
<svg width={500} height={300}>
{/* TODO */}
</svg>
);
};
6 changes: 6 additions & 0 deletions viz/exercise/SvgOverflowPractice/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 { Graph } from './Graph';

const rootElement = document.getElementById('root');
ReactDOM.render(<Graph />, rootElement);
28 changes: 28 additions & 0 deletions viz/exercise/SvgOverflowPractice/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"
]
}
7 changes: 7 additions & 0 deletions viz/exercise/SvgOverflowSolution/Graph.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export const Graph = () => {
return (
<svg width={500} height={300} style={{ overflow: 'visible' }}>
<circle cx={100} cy={290} r={70} fill="red" />
</svg>
);
};
6 changes: 6 additions & 0 deletions viz/exercise/SvgOverflowSolution/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 { Graph } from './Graph';

const rootElement = document.getElementById('root');
ReactDOM.render(<Graph />, rootElement);
28 changes: 28 additions & 0 deletions viz/exercise/SvgOverflowSolution/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 e5cc78d

Please sign in to comment.