Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(showcase): embed section #89

Merged
merged 4 commits into from
May 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions content/projects/sample.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ content:
controls: true
muted: true

- type: embed
content:
code: '<iframe src="https://player.vimeo.com/video/333541450" width="640" height="270" frameborder="0" allow="autoplay; fullscreen" allowfullscreen></iframe>'

- type: text
theme: dark
content:
Expand Down
10 changes: 10 additions & 0 deletions src/components/Projects/Section/sections/Embed/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from 'react'

import { IEmbed } from '../../types'
import { Wrapper } from './styled'

const Embed = (props: IEmbed) => {
return <Wrapper dangerouslySetInnerHTML={{ __html: props.code }} />
}

export default Embed
15 changes: 15 additions & 0 deletions src/components/Projects/Section/sections/Embed/styled.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import styled from '@theme'

export const Wrapper = styled.div`
position: relative;
padding-bottom: 56.25%; /* 16:9 */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we safely assume that it's always 16:9?

cc @pedroet

height: 0;

iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
`
1 change: 1 addition & 0 deletions src/components/Projects/Section/sections/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ export { default as waterfall } from './Waterfall'
export { default as testimonial } from './Testimonial'
export { default as sticky } from './Sticky'
export { default as highlight } from './Highlight'
export { default as embed } from './Embed'
7 changes: 7 additions & 0 deletions src/components/Projects/Section/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ export interface IStickyImage extends IStickyBase {

export type ISticky = IStickyVideo | IStickyImage

// Embed
export interface IEmbed {
pdrbrnd marked this conversation as resolved.
Show resolved Hide resolved
code: string
}

// Highlight
export interface IHighlight {
text: string
Expand All @@ -128,6 +133,7 @@ export type sectionTypes =
| 'testimonial'
| 'sticky'
| 'highlight'
| 'embed'
export type SectionContent =
| IText
| IImage
Expand All @@ -139,6 +145,7 @@ export type SectionContent =
| ITestimonial
| ISticky
| IHighlight
| IEmbed

export interface ISection {
type: sectionTypes
Expand Down
1 change: 1 addition & 0 deletions src/components/Projects/Section/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const defaultValues: { [K in sectionTypes]: layoutTypes } = {
video: 'normal',
waterfall: 'large',
highlight: 'normal',
embed: 'normal',
}

const getProjectSectionWidth = (type: sectionTypes, layout?: layoutTypes) => {
Expand Down
3 changes: 3 additions & 0 deletions src/templates/project.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,9 @@ export const query = graphql`
# Highlight

#text

# Embed
code
pdrbrnd marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
Expand Down