Finish landing

This commit is contained in:
Jorik Schellekens 2020-06-25 00:41:56 +01:00
parent 4b35d635c9
commit 862f57043b
20 changed files with 854 additions and 433 deletions

2
.gitignore vendored
View file

@ -21,3 +21,5 @@
npm-debug.log* npm-debug.log*
yarn-debug.log* yarn-debug.log*
yarn-error.log* yarn-error.log*
.vercel

View file

@ -6,14 +6,19 @@
"@testing-library/jest-dom": "^4.2.4", "@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.3.2", "@testing-library/react": "^9.3.2",
"@testing-library/user-event": "^7.1.2", "@testing-library/user-event": "^7.1.2",
"@types/classnames": "^2.2.10",
"@types/jest": "^24.0.0", "@types/jest": "^24.0.0",
"@types/node": "^12.0.0", "@types/node": "^12.0.0",
"@types/react": "^16.9.0", "@types/react": "^16.9.0",
"@types/react-dom": "^16.9.0", "@types/react-dom": "^16.9.0",
"@types/yup": "^0.29.3",
"classnames": "^2.2.6",
"formik": "^2.1.4",
"react": "^16.13.1", "react": "^16.13.1",
"react-dom": "^16.13.1", "react-dom": "^16.13.1",
"react-scripts": "3.4.1", "react-scripts": "3.4.1",
"typescript": "~3.7.2" "typescript": "~3.7.2",
"yup": "^0.29.1"
}, },
"scripts": { "scripts": {
"start": "react-scripts start", "start": "react-scripts start",
@ -24,7 +29,7 @@
}, },
"lint-staged": { "lint-staged": {
"src/**/*.{js,jsx,ts,tsx}": [ "src/**/*.{js,jsx,ts,tsx}": [
"eslint", "eslint --fix",
"prettier --write --tab-width 4", "prettier --write --tab-width 4",
"git add" "git add"
], ],

View file

@ -23,7 +23,7 @@ limitations under the License.
.topSpacer { .topSpacer {
@include spacer; @include spacer;
height: 30vh; height: 10vh;
} }
.bottomSpacer { .bottomSpacer {

View file

@ -18,11 +18,13 @@ import React from "react";
import "./App.scss"; import "./App.scss";
import SingleColumn from "./layouts/SingleColumn"; import SingleColumn from "./layouts/SingleColumn";
import CreateLinkTile from "./components/CreateLinkTile";
const App: React.FC = () => { const App: React.FC = () => {
return ( return (
<SingleColumn> <SingleColumn>
<div className="topSpacer" /> <div className="topSpacer" />
<CreateLinkTile />
<div className="bottomSpacer" /> <div className="bottomSpacer" />
</SingleColumn> </SingleColumn>
); );

View file

@ -4,3 +4,5 @@ $foreground: #000000;
$font: #333333; $font: #333333;
$grey: #666666; $grey: #666666;
$accent: #0098d4; $accent: #0098d4;
$error: #d6001c;
$link: #0098d4;

4
src/_error.scss Normal file
View file

@ -0,0 +1,4 @@
@mixin error {
color: $error;
border-color: $error;
}

View file

@ -20,14 +20,14 @@ limitations under the License.
width: 100%; width: 100%;
padding: 1rem; padding: 1rem;
border-radius: 1000px; border-radius: 2rem;
border: 0; border: 0;
background-color: $foreground; background-color: $foreground;
color: $background; color: $background;
font-size: 14px; font-size: 14px;
font-weight: 500px; font-weight: 500;
} }
.buttonHighlight { .buttonHighlight {

View file

@ -27,13 +27,13 @@ interface IProps extends React.ButtonHTMLAttributes<Element> {
/** /**
* Like a normal button except it will flash content when clicked. * Like a normal button except it will flash content when clicked.
*/ */
const Button: React.FC<IProps> = ({ const Button: React.FC<
onClick, IProps & React.RefAttributes<HTMLButtonElement>
children, > = React.forwardRef(
flashChildren, (
className, { onClick, children, flashChildren, className, ...restProps }: IProps,
...restProps ref: React.Ref<HTMLButtonElement>
}: IProps) => { ) => {
const [wasClicked, setWasClicked] = React.useState(false); const [wasClicked, setWasClicked] = React.useState(false);
const wrappedOnClick: React.MouseEventHandler = (e) => { const wrappedOnClick: React.MouseEventHandler = (e) => {
@ -47,17 +47,23 @@ const Button: React.FC<IProps> = ({
}, 1000); }, 1000);
}; };
const content = wasClicked ? flashChildren : children; const content = wasClicked && flashChildren ? flashChildren : children;
const classNames = classnames("button", className, { const classNames = classnames("button", className, {
buttonHighlight: wasClicked, buttonHighlight: wasClicked,
}); });
return ( return (
<button className={classNames} onClick={wrappedOnClick} {...restProps}> <button
className={classNames}
onClick={wrappedOnClick}
ref={ref}
{...restProps}
>
{content} {content}
</button> </button>
); );
}; }
);
export default Button; export default Button;

View file

@ -0,0 +1,30 @@
/*
Copyright 2020 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
.createLinkTile {
background: none;
> * {
margin: 12px 0;
width: 100%;
}
> form {
display: grid;
row-gap: 24px;
align-self: center;
}
}

View file

@ -0,0 +1,116 @@
/*
Copyright 2020 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import React, { useEffect, useRef } from "react";
import Tile from "./Tile";
import Button from "./Button";
import TextButton from "./TextButton";
import Input from "./Input";
import { Formik, Form } from "formik";
import * as Yup from "yup";
import "./CreateLinkTile.scss";
interface ILinkNotCreatedTileProps {
setLink: React.Dispatch<React.SetStateAction<string>>;
}
const LinkNotCreatedTile = (props: ILinkNotCreatedTileProps) => {
return (
<Tile className="createLinkTile">
<h1>
Create shareable links to Matrix rooms, users or messages
without being tied to any app
</h1>
<Formik
initialValues={{
identifier: "",
}}
validationSchema={Yup.object({
identifier: Yup.string()
.test(
"is-identifier",
"That link doesn't look right. Double check the details.",
(link) => link
)
.required("Required"),
})}
onSubmit={(values) => {
props.setLink(
document.location.protocol +
"//" +
document.location.host +
"/" +
values.identifier
);
}}
>
<Form>
<Input
name={"identifier"}
type={"text"}
placeholder="#room:example.com, @user:example.com"
/>
<Button type="submit">Get Link</Button>
</Form>
</Formik>
</Tile>
);
};
interface ILinkCreatedTileProps {
link: string;
setLink: React.Dispatch<React.SetStateAction<string>>;
}
const LinkCreatedTile: React.FC<ILinkCreatedTileProps> = (props) => {
const buttonRef = useRef<HTMLButtonElement>(null);
// Focus button on render
useEffect(() => {
if (buttonRef && buttonRef.current) {
buttonRef.current.focus();
}
});
return (
<Tile className="createLinkTile">
<TextButton onClick={() => props.setLink("")}>
Create another lnk
</TextButton>
<h1>{props.link}</h1>
<Button
flashChildren={"Copied"}
onClick={() => navigator.clipboard.writeText(props.link)}
ref={buttonRef}
>
Copy Link
</Button>
</Tile>
);
};
const CreateLinkTile: React.FC = () => {
const [link, setLink] = React.useState("");
console.log(link);
if (!link) {
return <LinkNotCreatedTile setLink={setLink} />;
} else {
return <LinkCreatedTile link={link} setLink={setLink} />;
}
};
export default CreateLinkTile;

40
src/components/Input.scss Normal file
View file

@ -0,0 +1,40 @@
/*
Copyright 2020 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
@import "../color-scheme";
@import "../error";
.input {
width: 100%;
padding: 12px;
background: $background;
border: 1px solid $font;
border-radius: 24px;
font-size: 14px;
line-height: 24px;
&.error {
@include error;
}
}
.inputError {
@include error;
text-align: center;
}

48
src/components/Input.tsx Normal file
View file

@ -0,0 +1,48 @@
/*
Copyright 2020 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import React from "react";
import classnames from "classnames";
import { useField } from "formik";
import "./Input.scss";
interface IProps extends React.InputHTMLAttributes<Element> {
name: string;
type: string;
}
const Input: React.FC<IProps> = ({ className, ...props }) => {
const [field, meta] = useField(props);
const error =
meta.touched && meta.error ? (
<div className="inputError">{meta.error}</div>
) : null;
const classNames = classnames("input", className, {
error: meta.error,
});
return (
<>
<input type="text" className={classNames} {...field} {...props} />
{error}
</>
);
};
export default Input;

View file

@ -0,0 +1,27 @@
/*
Copyright 2020 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
@import "../color-scheme";
.textButton {
background: none;
border: none;
color: $link;
font-style: normal;
font-weight: normal;
font-size: 14px;
line-height: 24px;
}

View file

@ -0,0 +1,33 @@
/*
Copyright 2020 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import React from "react";
import classnames from "classnames";
import "./TextButton.scss";
const TextButton: React.FC<React.ButtonHTMLAttributes<Element>> = ({
className,
...restProps
}) => {
return (
<button
className={classnames("textButton", className)}
{...restProps}
/>
);
};
export default TextButton;

View file

@ -24,4 +24,7 @@ limitations under the License.
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center;
text-align: center;
} }

View file

@ -15,15 +15,21 @@ limitations under the License.
*/ */
import React from "react"; import React from "react";
import classnames from "classnames";
import "./Tile.scss"; import "./Tile.scss";
interface IProps { interface IProps {
className?: string;
children: React.ReactNode; children: React.ReactNode;
} }
const Tile: React.FC<IProps> = (props: IProps) => { const Tile: React.FC<IProps> = (props: IProps) => {
return <div className="tile">{props.children}</div>; return (
<div className={classnames("tile", props.className)}>
{props.children}
</div>
);
}; };
export default Tile; export default Tile;

View file

@ -44,3 +44,8 @@ h1 {
line-height: 32px; line-height: 32px;
text-align: center; text-align: center;
} }
a {
color: $link;
text-decoration: none;
}

1
src/typings/react-app-env.d.ts vendored Normal file
View file

@ -0,0 +1 @@
/// <reference types="react-scripts" />

10
src/typings/scss.d.ts vendored Normal file
View file

@ -0,0 +1,10 @@
// scss.d.ts
declare module "*.css" {
const content: { [className: string]: string };
export default content;
}
declare module "*.scss" {
const content: { [className: string]: string };
export default content;
}

857
yarn.lock

File diff suppressed because it is too large Load diff