Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3c1e73e
commit 2ca4445
Showing
9 changed files
with
516 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,221 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; | ||
|
||
import { TableOfContents } from '../../../layouts/components/toc'; | ||
import { Headline } from '../../../layouts/components/headline'; | ||
import { Pagination } from '../../../layouts/components/pagination'; | ||
import { toc } from './toc'; | ||
import { CodeBlock } from '../../../layouts/components/codeblock'; | ||
import { FormatString } from '../../../utils/string'; | ||
|
||
export const MarginPage: React.FC<any> = (props) => { | ||
const sizes = [0, 1, 2, 3, 4, 5, 6, 8, 10, 12, 16, 20, 24, 32]; | ||
const types = [ | ||
{ | ||
class: `m-(0)`, | ||
style: `margin: (0) !important;`, | ||
}, | ||
{ | ||
class: `mx-(0)`, | ||
style: `margin-left: (0) !important; margin-right: (0) !important;`, | ||
}, | ||
{ | ||
class: `my-(0)`, | ||
style: `margin-top: (0) !important; margin-bottom: (0) !important;`, | ||
}, | ||
{ | ||
class: `mt-(0)`, | ||
style: `margin-top: (0) !important;`, | ||
}, | ||
{ | ||
class: `mb-(0)`, | ||
style: `margin-bottom: (0) !important;`, | ||
}, | ||
{ | ||
class: `ml-(0)`, | ||
style: `margin-left: (0) !important;`, | ||
}, | ||
{ | ||
class: `mr-(0)`, | ||
style: `margin-right: (0) !important;`, | ||
}, | ||
]; | ||
let [classTable, setClassTable] = useState([] as any[]); | ||
|
||
useEffect(() => { | ||
const rows = types.map((type) => { | ||
return sizes.map((size) => { | ||
return { | ||
class: FormatString(type.class, size.toString()), | ||
style: FormatString(type.style, `${0.5 * size}rem`), | ||
}; | ||
}); | ||
}); | ||
console.log(rows); | ||
setClassTable(([] as any).concat(...rows)); | ||
}, []); | ||
|
||
return ( | ||
<main className="page-layout"> | ||
<div> | ||
<section className="padtop" id="margin"> | ||
<div className="content"> | ||
<Headline title="Margin" link="#margin" /> | ||
<div className="divider"></div> | ||
<p>These are utility classes used to add margins for any element.</p> | ||
</div> | ||
</section> | ||
|
||
<section className="padtop" id="sizes"> | ||
<div className="content"> | ||
<Headline title="Sizes" link="#sizes" size="4" /> | ||
<div className="divider"></div> | ||
<p> | ||
These are the different sizes supported for margins. Note that all calculations are based | ||
around <code>0.5rem</code> or <code>8px</code>. | ||
</p> | ||
|
||
<table className="table fixed-head u-text-left"> | ||
<thead> | ||
<tr> | ||
<th | ||
style={{ | ||
width: '200px', | ||
}} | ||
> | ||
Class | ||
</th> | ||
<th>Styles</th> | ||
</tr> | ||
</thead> | ||
<tbody | ||
style={{ | ||
height: '500px', | ||
}} | ||
> | ||
{classTable.map((row) => ( | ||
<tr> | ||
<td | ||
style={{ | ||
width: '200px', | ||
}} | ||
> | ||
<code className="text-blue-600 bg-blue-100">{row.class}</code> | ||
</td> | ||
<td> | ||
<code>{row.style}</code> | ||
</td> | ||
</tr> | ||
))} | ||
</tbody> | ||
</table> | ||
</div> | ||
</section> | ||
|
||
<section className="padtop" id="all"> | ||
<div className="content"> | ||
<Headline title="All Sides" link="#all" size="4" /> | ||
<div className="divider"></div> | ||
<p> | ||
Add a margin on all sides of an element using the <code>m-<size></code> class. | ||
</p> | ||
|
||
<div className="row"> | ||
<div className="col u-flex u-justify-center"> | ||
<div className="bg-indigo-200 u-inline-flex"> | ||
<span className="bg-indigo-500 p-1 m-4 white"> | ||
m-4 | ||
</span> | ||
</div> | ||
</div> | ||
</div> | ||
<div className="space"></div> | ||
<CodeBlock code={`<div class="bg-indigo-200 u-inline-flex"><span class="bg-indigo-500 p-1 m-4 white">m-4</span></div>`} language="htmlbars" /> | ||
</div> | ||
</section> | ||
|
||
<section className="padtop" id="both"> | ||
<div className="content"> | ||
<Headline title="Both Sides" link="#both" size="4" /> | ||
<div className="divider"></div> | ||
<p> | ||
Add a margin to either left and right or top and bottom with the{' '} | ||
<code>mx-<size></code> and <code>my-<size></code> classes respectively. | ||
</p> | ||
|
||
<div className="row"> | ||
<div className="col u-flex u-justify-center"> | ||
<div className="bg-indigo-200 u-inline-flex"> | ||
<span className="bg-indigo-500 p-1 mx-4 white"> | ||
mx-4 | ||
</span> | ||
</div> | ||
</div> | ||
<div className="col u-flex u-justify-center"> | ||
<div className="bg-indigo-200 u-inline-flex"> | ||
<span className="bg-indigo-500 p-1 my-4 white"> | ||
my-4 | ||
</span> | ||
</div> | ||
</div> | ||
</div> | ||
<div className="space"></div> | ||
<CodeBlock code={`<div class="bg-indigo-200 u-inline-flex"><span class="bg-indigo-500 p-1 mx-4 white">mx-4</span></div> | ||
<div class="bg-indigo-200 u-inline-flex"><span class="bg-indigo-500 p-1 my-4 white">my-4</span></div>`} language="htmlbars" /> | ||
</div> | ||
</section> | ||
|
||
<section className="padtop" id="single"> | ||
<div className="content"> | ||
<Headline title="Single Side" link="#single" size="4" /> | ||
<div className="divider"></div> | ||
<p>For adding a margin for only a single side, the class follows a convention like <code>m<l|r|t|b>-<size></code>.</p> | ||
|
||
|
||
<div className="row"> | ||
<div className="col u-flex u-justify-center"> | ||
<div className="bg-indigo-200 u-inline-flex"> | ||
<span className="bg-indigo-500 p-1 ml-4 white"> | ||
ml-4 | ||
</span> | ||
</div> | ||
</div> | ||
<div className="col u-flex u-justify-center"> | ||
<div className="bg-indigo-200 u-inline-flex"> | ||
<span className="bg-indigo-500 p-1 mr-4 white"> | ||
mr-4 | ||
</span> | ||
</div> | ||
</div> | ||
<div className="col u-flex u-justify-center"> | ||
<div className="bg-indigo-200 u-inline-flex"> | ||
<span className="bg-indigo-500 p-1 mt-4 white"> | ||
mt-4 | ||
</span> | ||
</div> | ||
</div> | ||
<div className="col u-flex u-justify-center"> | ||
<div className="bg-indigo-200 u-inline-flex"> | ||
<span className="bg-indigo-500 p-1 mb-4 white"> | ||
mb-4 | ||
</span> | ||
</div> | ||
</div> | ||
</div> | ||
<div className="space"></div> | ||
<CodeBlock code={`<div class="bg-indigo-200 u-inline-flex"><span class="bg-indigo-500 p-1 ml-4 white">ml-4</span></div> | ||
<div class="bg-indigo-200 u-inline-flex"><span class="bg-indigo-500 p-1 mr-4 white">mr-4</span></div> | ||
<div class="bg-indigo-200 u-inline-flex"><span class="bg-indigo-500 p-1 mt-4 white">mt-4</span></div> | ||
<div class="bg-indigo-200 u-inline-flex"><span class="bg-indigo-500 p-1 mb-4 white">mb-4</span></div>`} language='htmlbars' /> | ||
</div> | ||
</section> | ||
|
||
<Pagination | ||
prevLink={{ name: 'Hero', link: './hero' }} | ||
nextLink={{ name: 'Media', link: './media' }} | ||
/> | ||
</div> | ||
<TableOfContents entries={toc} /> | ||
</main> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { TableOfContentsEntry } from '../../../layouts/components/toc'; | ||
|
||
export const toc: TableOfContentsEntry[] = [ | ||
{ | ||
name: 'Padding', | ||
anchor: '#padding', | ||
children: [ | ||
{ | ||
name: 'Sizes', | ||
anchor: '#sizes', | ||
children: null, | ||
}, | ||
{ | ||
name: 'All Sides', | ||
anchor: '#all', | ||
children: null, | ||
}, | ||
{ | ||
name: 'Both Sides', | ||
anchor: '#both', | ||
children: null, | ||
}, | ||
{ | ||
name: 'Single Side', | ||
anchor: '#single', | ||
children: null, | ||
}, | ||
], | ||
}, | ||
]; |
Oops, something went wrong.