Skip to content

Commit

Permalink
feat: added Frame title
Browse files Browse the repository at this point in the history
  • Loading branch information
CyriacBr committed May 30, 2020
1 parent 23c64b2 commit b0c0620
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
6 changes: 5 additions & 1 deletion example/components/Frame.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import React, { useState } from 'react';

export interface FrameProps {
title: string;
bg: string;
color: string;
}

export const Frame: React.FC<FrameProps> = ({ children, bg, color }) => {
export const Frame: React.FC<FrameProps> = ({ children, bg, color, title }) => {
const [reload, setReload] = useState(0);
return (
<div
Expand All @@ -15,6 +16,9 @@ export const Frame: React.FC<FrameProps> = ({ children, bg, color }) => {
onClick={() => setReload(v => v + 1)}
>
{children}
<span className="frame-title" style={{ color }}>
{title}
</span>
</div>
);
};
2 changes: 1 addition & 1 deletion example/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import './styles.css';
const App = () => {
return (
<div style={{ display: 'flex', flexWrap: 'wrap' }}>
<Frame bg="#F56565" color="#F7FAFC">
<Frame bg="#F56565" color="#F7FAFC" title="Fade In">
<FadeIn />
</Frame>
</div>
Expand Down
11 changes: 11 additions & 0 deletions example/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,15 @@ body {
text-align: center;
align-items: center;
cursor: pointer;
position: relative;
}

.frame-title {
position: absolute;
left: 0;
right: 0;
padding-top: 1rem;
text-decoration: underline;
align-self: flex-start;
font-size: 1.5rem;
}

0 comments on commit b0c0620

Please sign in to comment.