1
0
mirror of https://github.com/phuoc-ng/csslayout.git synced 2025-08-30 00:59:47 +02:00

Add dot navigation

This commit is contained in:
Phuoc Nguyen
2019-11-22 19:16:27 +07:00
parent df265ba464
commit 912957405b
4 changed files with 107 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
import React from 'react';
import Frame from '../../placeholders/Frame';
const Cover = () => {
return (
<Frame>
<div className="h-100 flex flex-column items-center justify-center">
<div className="flex items-center">
<div className="mh1 br-pill ba b--black-30" style={{ height: '8px', width: '8px' }} />
<div className="mh1 br-pill bg-black-30" style={{ height: '8px', width: '8px' }} />
<div className="mh1 br-pill ba b--black-30" style={{ height: '8px', width: '8px' }} />
<div className="mh1 br-pill ba b--black-30" style={{ height: '8px', width: '8px' }} />
</div>
</div>
</Frame>
);
};
export default Cover;

View File

@@ -0,0 +1,78 @@
import React, { useState } from 'react';
import DetailsLayout from '../../DetailsLayout';
import BrowserFrame from '../../placeholders/BrowserFrame';
import SampleCode from '../../SampleCode';
const Details = () => {
const [activeItem, setActiveItem] = useState(0);
const Dot = ({ index }) => {
const isActive = index === activeItem;
const click = () => setActiveItem(index);
return (
<li
className={`pointer mh1 br-pill ${isActive ? 'bg-black-30' : 'ba b--black-30'}`}
style={{
height: '12px',
width: '12px',
}}
onClick={click}
/>
);
};
return (
<DetailsLayout title="Dot navigation">
<BrowserFrame
content={
<div className="h-100 flex flex-column items-center justify-center">
<ul className="list ma0 pa0 flex items-center justify-center">
<Dot index={0} />
<Dot index={1} />
<Dot index={2} />
<Dot index={3} />
</ul>
</div>
}
source={
<SampleCode
lang="html"
code={`
<ul style="
/* Content is centered */
align-items: center;
display: flex;
justify-content: center;
/* Reset styles */
list-style-type: none;
margin: 0;
padding: 0;
">
<li style="
/* Rounded border */
border-radius: 9999px;
height: 12px;
width: 12px;
/* Active dot */
background-color: rgba(0, 0, 0, .3);
/* Inactive dot */
background-color: transparent;
border: 1px solid rgba(0, 0, 0, .3);
/* OPTIONAL: Spacing between dots */
margin: 0 4px;
" />
</div>
`}
/>
}
/>
</DetailsLayout>
);
};
export default Details;