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

refactor(MainLayout): HTML Markups and editor tabs #9

Open
wants to merge 2 commits into
base: master
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
19 changes: 9 additions & 10 deletions src/components/editor/EditorComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,11 @@ function EditorComponent({
}
}}
>
<CloseSVG color="#8d9aaf"/>
<CloseSVG/>
</button>}
{hasCloneBtn && <FlexBox className="editor-actions">
<button>
<CopySVG color="#8d9aaf"/>
<CopySVG/>
<style>{`
.editor-actions{
padding: 0 20px 15px;
Expand All @@ -174,12 +174,10 @@ function EditorComponent({
</FlexBox>}
<style>{`
.editor-box{
width: 50%;
background-color: white;
position: relative;
margin-right: 7px;
box-shadow: 0 1px 3px -1px rgba(0,0,0,0.1);
border-radius: 4px;
box-shadow: 0 2px 5px #eff3fb, 0 10px 20px #eff3fb;
}
.editor-box p{
margin:0;
Expand All @@ -192,14 +190,15 @@ function EditorComponent({
.editor-box button:focus{
outline: none;
}

.editor-box + .editor-box {
margin-left: 7px;
margin-right: 0;
}
.editor-box .editor{
border-radius: 4px
}
.editor-box svg{
opacity: .5;
}
.editor-box button:hover svg{
opacity: 1;
}
.editor-box .close-button{
position:absolute;
top: 17px;
Expand Down
10 changes: 8 additions & 2 deletions src/components/icons/LogoSVG.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import React from "react";

export default function LogoSVG(): JSX.Element {
const RATIO = 3.431818181818181;

interface IProps {
height: number
}

export default function LogoSVG({height}: IProps): JSX.Element {
return (
<svg xmlns="http://www.w3.org/2000/svg" width="151" height="44" viewBox="0 0 151 44">
<svg xmlns="http://www.w3.org/2000/svg" width={height * RATIO} height={height} viewBox="0 0 151 44">
<g fill="none" fillRule="evenodd">
<path fill="#FFBB4B" d="M12 11a6 6 0 1 1-12 0 6 6 0 0 1 12 0"/>
<path fill="#FF4E4E" d="M32.619 11a6 6 0 1 1-12 0 6 6 0 0 1 12 0"/>
Expand Down
2 changes: 1 addition & 1 deletion src/components/layout/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default function Footer() {
</ContainerBox>
<style jsx>{`
.main-footer {
height: 92px;
height: 70px;
display:flex;
align-items:center;
background-color: #ffffff;
Expand Down
5 changes: 3 additions & 2 deletions src/components/layout/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,18 @@ export default function Header() {
<FlexBox>
<Link href="/">
<a>
<LogoSVG/>
<LogoSVG height={36}/>
</a>
</Link>
</FlexBox>
</ContainerBox>
<style jsx>{`
.main-header {
height: 92px;
height: 70px;
display:flex;
align-items:center;
background-color: #ffffff;
box-shadow: 0 2px 2px #eff3fb,0 10px 15px #eff3fb;
}
`}</style>
</header>
Expand Down
7 changes: 6 additions & 1 deletion src/components/layout/MainLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,18 @@ export default function MainLayout({pageTitle, customHead, children}: IProps): J
{`
body {
margin: 0;
color: #6a7990;
font-size: 1rem;
font-family: Roboto,Arial,Helvetica,sans-serif;
font-weight: 400;
line-height: 1.5;
background-color: #fbfcfe;
}
html,
input,
textarea {
font-family: "Roboto", sans-serif;
line-height: 1.4;
background: #FDFDFD;
}
p {
margin: 0 0 15px;
Expand Down
87 changes: 71 additions & 16 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,39 @@
import React, {useCallback, useRef, useState} from "react"
import {debounce} from "lodash"
import {debounce, isEqual} from "lodash"
import EditorComponent from "../components/editor/EditorComponent"
import {Value} from "slate"
import initialJson from "../components/editor/editor_value.json"
import MainLayout from "../components/layout/MainLayout"
import * as editorUtils from "../helpers/editorUtils"
import FlexBox from "../components/box/FlexBox"
import Link from "next/link";

const initialValue = Value.fromJSON(initialJson)

export default function IndexPage(): JSX.Element {
interface IProps {
url: any
}

const TABS = [
{
code: "auto",
query: {},
title: "Avtomatik aniqlash"
},
{
code: "lat2cyr",
query: {tab: "lat2cyr"},
title: "Lotin"
},
{
code: "cyr2lat",
query: {tab: "cyr2lat"},
title: "Kiril"
},
]

export default function IndexPage({url}: IProps): JSX.Element {
console.log("test === ", url)
const [leftValue, setLeftValue] = useState<Value>(initialValue)
const [rightValue, setRightValue] = useState<Value>(initialValue)
const leftEditor = useRef<any>()
Expand All @@ -32,21 +57,51 @@ export default function IndexPage(): JSX.Element {
return (
<MainLayout pageTitle="Tekshir.uz">
<FlexBox style={{justifyContent: "space-between"}}>
<EditorComponent
editor={leftEditor}
onClear={onClearEditors}
placeholder="Matnni bu yerga kiriting"
autoFocus={true}
hasClearBtn={true}
value={leftValue}
onChange={onLeftChange}
onContentChange={convertToRight}
/>
<EditorComponent
placeholder="Oʻgirilgan matn bu yerda chiqadi"
editor={rightEditor}
value={rightValue}
<FlexBox direction={"column"} style={{width: "49%"}}>
<FlexBox className="editor-header">
{TABS.map(tab =>
<Link href={{pathname: "/", query: tab.query}}>
<a className={isEqual(url.query, tab.query) ? 'active' : 'no-active'}>
{tab.title}
</a>
</Link>
)}
</FlexBox>
<EditorComponent
editor={leftEditor}
onClear={onClearEditors}
placeholder="Matnni bu yerga kiriting"
autoFocus={true}
hasClearBtn={true}
value={leftValue}
onChange={onLeftChange}
onContentChange={convertToRight}
/>
</FlexBox>

<FlexBox direction={"column"} style={{width: "49%"}}>
<FlexBox className="editor-header">
<Link href="/?type=lat2cyr">Kiril</Link>
<Link href="/?type=cyr2lat">Lotin</Link>
</FlexBox>
<EditorComponent
placeholder="Oʻgirilgan matn bu yerda chiqadi"
editor={rightEditor}
value={rightValue}
/>
</FlexBox>
<style>{`
.editor-header a{
color: #8d9aaf;
text-decoration: none;
padding: 10px;

}
.editor-header a.active{
border-bottom: 2px solid rgba(0,0,0,0.5);

}
`}</style>
</FlexBox>
</MainLayout>
)
Expand Down
2 changes: 0 additions & 2 deletions src/pages/policy.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import React from "react"
import Link from "next/link"
import MainLayout from "../components/layout/MainLayout"

interface IProps {}

export default function IndexPage(props: IProps): JSX.Element {
// console.log(props)
return (
<MainLayout pageTitle={"Loyiha haqida"}>
<h2>Loyiha haqida</h2>
Expand Down