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

Update demo ui #19 #43

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
15 changes: 10 additions & 5 deletions src/demo/index.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
<!DOCTYPE html>
<html lang="en">
<head>

<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>react-copy-mailto</title>
</head>
<body style="background-color: papayawhip; font-family: sans-serif;">
<link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.0/normalize.min.css" rel="stylesheet">
</head>

<body>
<div id="app"></div>
</body>
</html>
</body>

</html>
97 changes: 88 additions & 9 deletions src/demo/index.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,94 @@
import React from "react";
import React, { useState } from "react";
import ReactDOM from "react-dom";

import CopyMailTo from "../lib";
import "./styles.css";

const App = () => (
<div
style={{ display: "flex", alignItems: "center", flexDirection: "column" }}
>
<h1 style={{ marginBottom: "50px" }}>Copy email address to clipboard</h1>
<CopyMailTo email="[email protected]" />
</div>
);
type themeOptions = "dark" | "light";

const App = () => {
const [theme, setTheme] = useState<themeOptions>("dark");
const [email, setEmail] = useState("[email protected]");
const [defaultTooltip, setDefaultTooltip] = useState("Copy email address");
const [copiedTooltip, setCopiedTooltip] = useState("Copied to clipboard!");

return (
<div className="container">
<div className="side-bar">
<a
href="https://github.com/devfolioco/react-copy-mailto"
target="_blank"
>
<div className="side-bar__segment side-bar__segment--header">
<h2>react-copy-mailto</h2>
</div>
</a>
<div className="side-bar__segment">
<label htmlFor="theme-inputs">theme
<select name="theme-inputs" value={theme} onChange={(e: any) => setTheme(e.target.value)}>
<option value="dark">dark</option>
<option value="light">light</option>
</select></label>
</div>
<div className="side-bar__segment">
<label htmlFor="email-inputs">
email
<input
id="email-inputs"
name="emailInputs"
type="email"
value={email}
onChange={(e: any) => setEmail(e.target.value)}
/>
</label>
</div>
<div className="side-bar__segment">
<label htmlFor="defaultTooltip-inputs">
defaultTooltip
<input
id="defaultTooltip-inputs"
name="defaultTooltip"
type="text"
value={defaultTooltip}
onChange={(e: any) => setDefaultTooltip(e.target.value)}
/>
</label>
</div>
<div className="side-bar__segment">
<label htmlFor="copiedTooltip-inputs">
copiedTooltip
<input
id="copiedTooltip-inputs"
name="copiedTooltip"
type="text"
value={copiedTooltip}
onChange={(e: any) => setCopiedTooltip(e.target.value)}
/>
</label>
</div>
<div className="side-bar__segment side-bar__segment--bottom">
<a href="https://github.com/devfolioco/react-copy-mailto">
Documentation and Source
</a>
</div>
</div>
<div className="view">
<div className="card">
<h1 style={{ marginBottom: "50px" }}>
Copy email address to clipboard
</h1>
<div className="emailStyle">
<CopyMailTo
theme={theme}
email={email}
defaultTooltip={defaultTooltip}
copiedTooltip={copiedTooltip}
/>
</div>
</div>
</div>
</div>
);
};

ReactDOM.render(<App />, document.getElementById("app"));
219 changes: 219 additions & 0 deletions src/demo/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@
body {
font-family: 'Lato', sans-serif;
font-size: 16px;
}

a {
text-decoration: none;
color: inherit;
}

.container {
display: flex;
width: 100%;
min-height: 100vh;
height: 100%;
}

.side-bar {
width: 250px;
box-shadow: 0 1px 3px 0 #d4d4d5, 0 0 0 1px #d4d4d5;
z-index: 1;
position: relative;
}

.inputStyle {
width: 3rem !important;
height: 3rem;
margin: 0 1rem;
font-size: 2rem;
border-radius: 4px;
border: 1px solid rgba(0, 0, 0, 0.3);
}

.emailStyle {
display: flex;
align-items: center;
flex-direction: column;
padding: 1em;
font-size: 1.25em;
border-radius: 4px;
border: 1px solid rgba(0, 0, 0, 0.3);
}

.emailStyle a {
text-decoration: underline;
color: blue;
}

@media only screen and (max-width: 678px) {
.container {
flex-wrap: wrap;
flex-direction: column;
}
.side-bar {
width: 100%;
display: flex;
flex-direction: column;
}
.side-bar__segment--header {
text-align: center;
}
.side-bar__segment--bottom {
position: static !important;
margin: 10px;
}
label {
display: block;
float: left;
width: 120px;
}
.card {
width: 100%;
min-width: 120px !important;
margin: 20px;
}
.side-bar__segment>label>input[type='number'],
.side-bar__segment>label>input[type='text'],
.side-bar__segment>label>input[type='email'] {
width: 180px !important;
}
}

@media only screen and (max-width: 470px) {
.margin-top--small .inputStyle {
width: 2rem !important;
height: 2rem;
margin: 0 5px;
font-size: 1rem;
}
.card>form>p {
font-size: 1.2em !important;
}
}

.side-bar__segment {
padding: 0.5rem 1rem;
}

.side-bar__segment--header {
margin: 1rem 0;
border-bottom: 1px solid lightgray;
border-top: 1px solid lightgray;
}

.side-bar__segment--header:hover {
background-color: rgba(0, 0, 0, 0.1);
}

.side-bar__segment--bottom {
font-weight: bold;
position: absolute;
bottom: 2rem;
}

.view {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
background-color: #f2f2f3;
}

.side-bar__segment>label>input[type='number'],
.side-bar__segment>label>input[type='text'],
.side-bar__segment>label>input[type='email'],
.side-bar__segment>label>select {
width: 150px;
border-radius: 4px;
border: 1px solid lightgrey;
margin: 0.5rem 0;
height: 1.5rem;
padding: 0 0.5rem;
}

.side-bar__segment>label>input[type='checkbox'] {
border-radius: 4px;
border: 1px solid lightgrey;
margin: 0.5rem;
width: 1rem;
height: 1rem;
}

.card {
min-width: 360px;
padding: 2rem;
box-shadow: 0 1px 3px 0 #d4d4d5, 0 0 0 1px #d4d4d5;
border-radius: 4px;
background: white;
}

.card>form {
display: flex;
flex-direction: column;
align-items: center;
}

.card>form>p {
font-size: 1.5em;
font-weight: bold;
}

input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
margin: 0;
}

input[type=number] {
-webkit-appearance: textfield;
-moz-appearance: textfield;
appearance: textfield;
}

.btn-row {
display: flex;
flex-direction: row;
}

.btn {
background-color: #3273dc;
border: none;
padding: 0.5rem 1rem;
color: white;
border-radius: 4px;
cursor: pointer;
margin: 1rem;
}

.btn:disabled {
background-color: rgba(0, 0, 0, 0.4);
cursor: default;
}

.margin-top--small {
margin-top: 1rem;
margin-bottom: -1rem;
}

.margin-top--small>div {
flex-wrap: wrap;
}

.margin-top--small>div>div {
margin-bottom: 1rem;
}

.margin-top--medium {
margin-top: 1.5rem;
}

.margin-top--large {
margin-top: 4rem;
}

.error {
border: 1px solid red !important;
}