mirror of
https://github.com/phuoc-ng/csslayout.git
synced 2025-08-06 06:07:33 +02:00
feat: Overlay play button
This commit is contained in:
7
contents/_includes/patterns/overlay-play-button.njk
Normal file
7
contents/_includes/patterns/overlay-play-button.njk
Normal file
@@ -0,0 +1,7 @@
|
||||
<div class="overlay-play-button">
|
||||
<div class="overlay-play-button__overlay">
|
||||
<div class="overlay-play-button__play">
|
||||
{% triangle "r" %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@@ -193,6 +193,12 @@ eleventyExcludeFromCollections: true
|
||||
<div class="pattern__title">Media object</div>
|
||||
</a>
|
||||
</div>
|
||||
<div class="pattern__item">
|
||||
<a class="pattern__link" href="/overlay-play-button/">
|
||||
<div class="pattern__cover">{% include "patterns/overlay-play-button.njk" %}</div>
|
||||
<div class="pattern__title">Overlay play button</div>
|
||||
</a>
|
||||
</div>
|
||||
<div class="pattern__item">
|
||||
<a class="pattern__link" href="/triangle-buttons/">
|
||||
<div class="pattern__cover">{% include "patterns/triangle-buttons.njk" %}</div>
|
||||
|
67
contents/overlay-play-button.md
Normal file
67
contents/overlay-play-button.md
Normal file
@@ -0,0 +1,67 @@
|
||||
---
|
||||
layout: layouts/post.njk
|
||||
title: Overlay play button
|
||||
description: Create an overlay play button with CSS flexbox
|
||||
keywords: css flexbox
|
||||
---
|
||||
|
||||
## HTML
|
||||
|
||||
```html
|
||||
<div class="overlay-play-button">
|
||||
<!-- The video element -->
|
||||
<video src="..." />
|
||||
|
||||
<!-- The overlay area -->
|
||||
<div class="overlay-play-button__overlay">
|
||||
<!-- The player button -->
|
||||
<div class="overlay-play-button__play">
|
||||
...
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
```
|
||||
|
||||
## CSS
|
||||
|
||||
```css
|
||||
.overlay-play-button {
|
||||
/* Used to position the overlay */
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.overlay-play-button__overlay {
|
||||
/* Position */
|
||||
left: 0;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
|
||||
/* Take full size */
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
|
||||
/* Center the content */
|
||||
align-items: center;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
|
||||
/* Add a dark background */
|
||||
background-color: rgba(0, 0, 0, 0.25);
|
||||
}
|
||||
|
||||
.overlay-play-button__play {
|
||||
border: 0.25rem solid #FFF;
|
||||
border-radius: 9999px;
|
||||
height: 3rem;
|
||||
width: 3rem;
|
||||
|
||||
/* Center the content */
|
||||
align-items: center;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
```
|
||||
|
||||
{% demo %}
|
||||
{% include "patterns/overlay-play-button.njk" %}
|
||||
{% enddemo %}
|
@@ -1,112 +0,0 @@
|
||||
import * as React from 'react';
|
||||
import Head from 'next/head';
|
||||
import { Spacer } from '@1milligram/design';
|
||||
|
||||
import { RelatedPatterns } from '../../components/RelatedPatterns';
|
||||
import { Pattern } from '../../constants/Pattern';
|
||||
import { PatternLayout } from '../../layouts/PatternLayout';
|
||||
import BrowserFrame from '../../placeholders/BrowserFrame';
|
||||
import Triangle from '../../placeholders/Triangle';
|
||||
|
||||
const Details: React.FC<{}> = () => {
|
||||
return (
|
||||
<PatternLayout pattern={Pattern.OverlayPlayButton}>
|
||||
<Head>
|
||||
<meta name="description" content="Create an overlay play button with CSS flexbox" />
|
||||
<meta name="og:description" content="Create an overlay play button with CSS flexbox" />
|
||||
<meta name="twitter:description" content="Create an overlay play button with CSS flexbox" />
|
||||
<meta name="keywords" content="css flexbox" />
|
||||
</Head>
|
||||
<BrowserFrame
|
||||
html={`
|
||||
<div class="container">
|
||||
<!-- The video element -->
|
||||
<video src="..." />
|
||||
|
||||
<!-- The overlay area -->
|
||||
<div class="container__overlay">
|
||||
<!-- The player button -->
|
||||
...
|
||||
</div>
|
||||
</div>
|
||||
`}
|
||||
css={`
|
||||
.container {
|
||||
/* Used to position the overlay */
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.container__overlay {
|
||||
/* Position */
|
||||
left: 0;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
|
||||
/* Take full size */
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
|
||||
/* Center the content */
|
||||
align-items: center;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
|
||||
/* Add a dark background */
|
||||
background-color: rgba(0, 0, 0, 0.25);
|
||||
}
|
||||
`}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
alignItems: 'center',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
height: '100%',
|
||||
justifyContent: 'center',
|
||||
padding: '8px',
|
||||
}}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
height: '100%',
|
||||
position: 'relative',
|
||||
width: '100%',
|
||||
}}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
alignItems: 'center',
|
||||
backgroundColor: 'rgba(0, 0, 0, 0.25)',
|
||||
display: 'flex',
|
||||
height: '100%',
|
||||
justifyContent: 'center',
|
||||
left: 0,
|
||||
position: 'absolute',
|
||||
top: 0,
|
||||
width: '100%',
|
||||
}}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
alignItems: 'center',
|
||||
border: '4px solid #FFF',
|
||||
borderRadius: '9999px',
|
||||
display: 'flex',
|
||||
height: '64px',
|
||||
justifyContent: 'center',
|
||||
width: '64px',
|
||||
}}
|
||||
>
|
||||
<Triangle backgroundColor="#FFF" corner="r" size={8} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</BrowserFrame>
|
||||
<Spacer size="extraLarge" />
|
||||
<RelatedPatterns patterns={[Pattern.VideoBackground]} />
|
||||
</PatternLayout>
|
||||
);
|
||||
};
|
||||
|
||||
export default Details;
|
@@ -1,58 +0,0 @@
|
||||
import * as React from 'react';
|
||||
|
||||
import Frame from '../../placeholders/Frame';
|
||||
import Triangle from '../../placeholders/Triangle';
|
||||
|
||||
const Cover: React.FC<{}> = () => {
|
||||
return (
|
||||
<Frame>
|
||||
<div
|
||||
style={{
|
||||
alignItems: 'center',
|
||||
display: 'flex',
|
||||
height: '100%',
|
||||
justifyContent: 'center',
|
||||
padding: '8px',
|
||||
}}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
height: '100%',
|
||||
position: 'relative',
|
||||
width: '100%',
|
||||
}}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
alignItems: 'center',
|
||||
backgroundColor: 'rgba(0, 0, 0, 0.25)',
|
||||
display: 'flex',
|
||||
height: '100%',
|
||||
justifyContent: 'center',
|
||||
left: 0,
|
||||
position: 'absolute',
|
||||
top: 0,
|
||||
width: '100%',
|
||||
}}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
alignItems: 'center',
|
||||
border: '2px solid #FFF',
|
||||
borderRadius: '9999px',
|
||||
display: 'flex',
|
||||
height: '32px',
|
||||
justifyContent: 'center',
|
||||
width: '32px',
|
||||
}}
|
||||
>
|
||||
<Triangle backgroundColor="#FFF" corner="r" size={8} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Frame>
|
||||
);
|
||||
};
|
||||
|
||||
export default Cover;
|
@@ -41,6 +41,7 @@
|
||||
@import './patterns/layered-card';
|
||||
@import './patterns/lined-paper';
|
||||
@import './patterns/media-object';
|
||||
@import './patterns/overlay-play-button';
|
||||
@import './patterns/triangle-buttons';
|
||||
@import './patterns/video-background';
|
||||
@import './patterns/voting';
|
||||
|
38
styles/patterns/_overlay-play-button.scss
Normal file
38
styles/patterns/_overlay-play-button.scss
Normal file
@@ -0,0 +1,38 @@
|
||||
.overlay-play-button {
|
||||
/* Used to position the overlay */
|
||||
position: relative;
|
||||
|
||||
/* Demo */
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.overlay-play-button__overlay {
|
||||
/* Position */
|
||||
left: 0;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
|
||||
/* Take full size */
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
|
||||
/* Center the content */
|
||||
align-items: center;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
|
||||
/* Add a dark background */
|
||||
background-color: rgba(0, 0, 0, 0.25);
|
||||
}
|
||||
|
||||
.overlay-play-button__play {
|
||||
border: 0.25rem solid #FFF;
|
||||
border-radius: 9999px;
|
||||
height: 3rem;
|
||||
width: 3rem;
|
||||
|
||||
align-items: center;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
Reference in New Issue
Block a user