|
| 1 | +/** |
| 2 | + * A collection of popular layouts and patterns made with CSS (https://csslayout.io) |
| 3 | + * (c) 2019 - 2021 Nguyen Huu Phuoc <https://twitter.com/nghuuphuoc> |
| 4 | + */ |
| 5 | + |
| 6 | +import * as React from 'react'; |
| 7 | +import { Helmet } from 'react-helmet'; |
| 8 | + |
| 9 | +import Heading from '../../components/Heading'; |
| 10 | +import Pattern from '../../constants/Pattern'; |
| 11 | +import DetailsLayout from '../../layouts/DetailsLayout'; |
| 12 | +import BrowserFrame from '../../placeholders/BrowserFrame'; |
| 13 | + |
| 14 | +import './inverted-corners.css'; |
| 15 | + |
| 16 | +const Details: React.FC<{}> = () => { |
| 17 | + return ( |
| 18 | + <DetailsLayout pattern={Pattern.InvertedCorners}> |
| 19 | + <Helmet> |
| 20 | + <meta name="description" content="Create inverted corners with CSS" /> |
| 21 | + <meta name="og:description" content="Create inverted corners with CSS" /> |
| 22 | + <meta name="twitter:description" content="Create inverted corners with CSS" /> |
| 23 | + <meta name="keywords" content="css border radius, css inverted border radius, css inverted corners" /> |
| 24 | + </Helmet> |
| 25 | + <BrowserFrame |
| 26 | +html={` |
| 27 | +<div class="inverted-corners"> |
| 28 | + ... |
| 29 | +</div> |
| 30 | +`} |
| 31 | +css={` |
| 32 | +:root { |
| 33 | + --inverted-corners-background: #52525B; |
| 34 | + --inverted-corners-size: 2rem; |
| 35 | +} |
| 36 | +
|
| 37 | +.inverted-corners { |
| 38 | + background-color: var(--inverted-corners-background); |
| 39 | +
|
| 40 | + /* Used to position the corner */ |
| 41 | + position: relative; |
| 42 | +} |
| 43 | +
|
| 44 | +.inverted-corners::before { |
| 45 | + content: ''; |
| 46 | +
|
| 47 | + /* Absolute position */ |
| 48 | + bottom: calc(-2 * var(--inverted-corners-size)); |
| 49 | + left: 0; |
| 50 | + position: absolute; |
| 51 | +
|
| 52 | + /* Size */ |
| 53 | + height: calc(2 * var(--inverted-corners-size)); |
| 54 | + width: var(--inverted-corners-size); |
| 55 | +
|
| 56 | + /* Border */ |
| 57 | + background-color: transparent; |
| 58 | + border-top-left-radius: var(--inverted-corners-size); |
| 59 | + box-shadow: var(--inverted-corners-background) |
| 60 | + 0px calc(-1 * var(--inverted-corners-size)) 0px 0px; |
| 61 | +} |
| 62 | +`} |
| 63 | + > |
| 64 | + <div |
| 65 | + style={{ |
| 66 | + alignItems: 'center', |
| 67 | + display: 'flex', |
| 68 | + flexDirection: 'column', |
| 69 | + height: '100%', |
| 70 | + justifyContent: 'center', |
| 71 | + padding: '1rem', |
| 72 | + }} |
| 73 | + > |
| 74 | + <div |
| 75 | + style={{ |
| 76 | + height: '8rem', |
| 77 | + width: '16rem', |
| 78 | + }} |
| 79 | + > |
| 80 | + <div className='inverted-corners'></div> |
| 81 | + </div> |
| 82 | + </div> |
| 83 | + </BrowserFrame> |
| 84 | + |
| 85 | + <section> |
| 86 | + <Heading title="Use case" /> |
| 87 | + |
| 88 | + <div |
| 89 | + style={{ |
| 90 | + height: '8rem', |
| 91 | + width: '16rem', |
| 92 | + }} |
| 93 | + > |
| 94 | + <div className='inverted-corners inverted-corners--speech'>Speech Bubble</div> |
| 95 | + </div> |
| 96 | + </section> |
| 97 | + </DetailsLayout> |
| 98 | + ); |
| 99 | +}; |
| 100 | + |
| 101 | +export default Details; |
0 commit comments