Skip to content

Commit

Permalink
massive refactor (never do this again)
Browse files Browse the repository at this point in the history
  • Loading branch information
tedraykov committed Jun 1, 2022
1 parent be57811 commit 0f784b5
Show file tree
Hide file tree
Showing 332 changed files with 3,171 additions and 32,934 deletions.
20 changes: 8 additions & 12 deletions assets/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@
--accents-7: #495057;
--accents-8: #343a40;
--accents-9: #212529;
--font-sans: 'Ubuntu', -apple-system, system-ui, BlinkMacSystemFont,
'Helvetica Neue', 'Helvetica', sans-serif;
}

[data-theme='dark'] {
Expand Down Expand Up @@ -65,6 +63,14 @@
--accents-9: #f8f9fa;
}

@font-face {
font-family: "Inter";
font-style: normal;
font-weight: 400 700;
font-display: optional;
src: url("/fonts/Inter.woff2") format("woff2");
}

*,
*:before,
*:after {
Expand All @@ -84,7 +90,6 @@ html {

html,
body {
font-family: var(--font-sans);
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
Expand Down Expand Up @@ -114,15 +119,6 @@ a {
animation-name: fadeIn;
}

.pswp img {
max-width: none;
object-fit: contain;
}

.pswp__img--placeholder--blank{
display: none !important;
}

@-webkit-keyframes fadeIn {
from {
opacity: 0;
Expand Down
8 changes: 0 additions & 8 deletions assets/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,5 @@
@import './components.css';

@tailwind base;

@layer base {
body {
font-family: 'Ubuntu', sans-serif;
}
}

@tailwind components;

@tailwind utilities;
27 changes: 0 additions & 27 deletions codegen.json

This file was deleted.

11 changes: 11 additions & 0 deletions codegen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Generate code from your GraphQL schema and operations with a simple CLI
# Read the docs: https://www.graphql-code-generator.com
overwrite: true
schema: "http://localhost:3000/graphql"
generates:
graphql/schema/index.d.ts:
plugins:
- "typescript"
config:
avoidOptionals: true
maybeValue: T
3 changes: 1 addition & 2 deletions components/auth/ForgotPassword.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { FC, useEffect, useState, useCallback } from 'react'
import { validate } from 'email-validator'
import useUI from '@hooks/useUI'
import { Logo, Button, Input } from '@components/ui'

Expand Down Expand Up @@ -27,7 +26,7 @@ const ForgotPassword: FC<Props> = () => {
const handleValidation = useCallback(() => {
// Unable to send form unless fields are valid.
if (dirty) {
setDisabled(!validate(email))
setDisabled(!Boolean(email))
}
}, [email, dirty])

Expand Down
6 changes: 2 additions & 4 deletions components/auth/LoginView.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import React, { FC, useEffect, useState, useCallback } from 'react'
import { Logo, Button, Input } from '@components/ui'
import useLogin from '@framework/auth/use-login'
import useUI from '@hooks/useUI'
import { validate } from 'email-validator'

interface Props {}

Expand All @@ -16,7 +14,7 @@ const LoginView: FC<Props> = () => {
const [disabled, setDisabled] = useState(false)
const { setModalView, closeModal } = useUI()

const login = useLogin()
const login = ({}: any) => {}

const handleLogin = async (e: React.SyntheticEvent<EventTarget>) => {
e.preventDefault()
Expand Down Expand Up @@ -49,7 +47,7 @@ const LoginView: FC<Props> = () => {

// Unable to send form unless fields are valid.
if (dirty) {
setDisabled(!validate(email) || password.length < 7 || !validPassword)
setDisabled(!Boolean(email) || password.length < 7 || !validPassword)
}
}, [email, password, dirty])

Expand Down
7 changes: 3 additions & 4 deletions components/auth/SignUpView.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { FC, useEffect, useState, useCallback } from 'react'
import { validate } from 'email-validator'
import { Info } from '@components/icons'
import useUI from '@hooks/useUI'
import { Logo, Button, Input } from '@components/ui'
import useSignup from '@framework/auth/use-signup'

interface Props {}

Expand All @@ -18,7 +16,8 @@ const SignUpView: FC<Props> = () => {
const [dirty, setDirty] = useState(false)
const [disabled, setDisabled] = useState(false)

const signup = useSignup()
// const signup = useSignup()
const signup = (args: any) => {}
const { setModalView, closeModal } = useUI()

const handleSignup = async (e: React.SyntheticEvent<EventTarget>) => {
Expand Down Expand Up @@ -53,7 +52,7 @@ const SignUpView: FC<Props> = () => {

// Unable to send form unless fields are valid.
if (dirty) {
setDisabled(!validate(email) || password.length < 7 || !validPassword)
setDisabled(!Boolean(email) || password.length < 7 || !validPassword)
}
}, [email, password, dirty])

Expand Down
4 changes: 2 additions & 2 deletions components/cart/CartItem/CartItem.module.scss
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
.root {
@apply flex flex-row space-x-8 py-8;
@apply flex flex-row space-x-8 py-4;
}

.title {
@apply font-bold text-lg cursor-pointer leading-6;
@apply font-bold cursor-pointer leading-6;
}

.price {
Expand Down
2 changes: 1 addition & 1 deletion components/cart/CartItem/CartItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Link from 'next/link'
import s from './CartItem.module.scss'
import { Trash, Plus, Minus } from '@components/icons'
import useUI from '@hooks/useUI'
import { CartItem as MOCCartItem } from '@framework/schema'
import { CartItem as MOCCartItem } from '@graphql/schema'
import useCart from '@hooks/cart/useCart'

interface CartItemProps {
Expand Down
4 changes: 2 additions & 2 deletions components/cart/CartSidebarView/CartSidebarView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ const CartSidebarView: FC = () => {
</ul>
</Fade>
</div>
<div className="flex-shrink-0 px-4 pt-24 lg:pt-10 sm:px-6">
<div className="flex-shrink-0 px-4 pb-4 pt-24 lg:pt-10 sm:px-6">
<CartSummary cart={cart} />
<div className="flex flex-row justify-end">
<Link href="/checkout" passHref>
<Button width="100%" onClick={handleClose}>
<Button className="w-full" onClick={handleClose}>
Завършви поръчката
</Button>
</Link>
Expand Down
2 changes: 1 addition & 1 deletion components/cart/CartSummary/CartSummary.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { FC, memo, useMemo } from 'react'
import HelpIcon from '@mui/icons-material/Help'
import { Tooltip } from '@mui/material'
import { Cart } from '@framework/schema'
import { Cart } from '@graphql/schema'

interface CartSummaryProps {
cart: Cart | undefined
Expand Down
4 changes: 2 additions & 2 deletions components/cart/CartView/CartView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ export const CartView: FC<CartViewProps> = ({
<div className="flex flex-row justify-end">
<div className="w-full md:w-md">
{isEmpty ? (
<Button href="/" Component="a" width="100%">
<Button href="/" Component="a" className="w-full">
Продължи с пазаруването
</Button>
) : (
<Button href="/checkout" Component="a" width="100%">
<Button href="/checkout" Component="a" className="w-full">
Завършване на поръчката
</Button>
)}
Expand Down
142 changes: 142 additions & 0 deletions components/catalog/CatalogCategories/CatalogCategories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
import type { FC } from 'react'
import { useState } from 'react'
import cn from 'classnames'
import { NavigationTree } from '@graphql/schema'
import { useRouter } from 'next/router'
import Link from 'next/link'

type CatalogCategoriesProps = {
categories: NavigationTree
}

const CatalogCategories: FC<CatalogCategoriesProps> = ({ categories }) => {
const [activeFilter, setActiveFilter] = useState('')
const [toggleFilter, setToggleFilter] = useState(false)

const { tag } = useRouter().query
const activeCategory = categories?.items.find((category) => {
return category.navigationItem.data.url.replace('/', '') === tag
})

const handleClick = (event: any, filter: string) => {
if (filter !== activeFilter) {
setToggleFilter(true)
} else {
setToggleFilter(!toggleFilter)
}
setActiveFilter(filter)
}

return (
<div className="relative inline-block w-full mb-6">
<div className="lg:hidden">
<span className="rounded-md shadow-sm">
<button
type="button"
onClick={(e) => handleClick(e, 'categories')}
className={`flex justify-between w-full rounded-sm border border-accent-3 px-4 py-3
bg-accent-0 text-sm leading-5 font-medium text-accent-4
hover:text-accent-5 focus:outline-none focus:border-blue-300 focus:shadow-outline-normal
active:bg-accent-1 active:text-accent-8 transition ease-in-out duration-150
`}
id="options-menu"
aria-haspopup="true"
aria-expanded="true"
>
{activeCategory?.navigationItem.data.contentForLanguage
? `Категория: ${activeCategory?.navigationItem.data.contentForLanguage}`
: 'Всички категории'}
<svg
className="-mr-1 ml-2 h-5 w-5"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 20 20"
fill="currentColor"
>
<path
fillRule="evenodd"
d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z"
clipRule="evenodd"
/>
</svg>
</button>
</span>
</div>
<div
className={`
origin-top-left absolute lg:relative left-0 mt-2
w-full rounded-md shadow-lg lg:shadow-none z-10 mb-10 lg:block
${activeFilter !== 'categories' || !toggleFilter ? 'hidden' : ''}
`}
>
<div className="rounded-sm bg-primary shadow-xs lg:bg-none lg:shadow-none z-20">
<div
role="menu"
aria-orientation="vertical"
aria-labelledby="options-menu"
>
<ul>
<li
className={cn(
`w-fit text-sm leading-5 text-accent-4
lg:text-base lg:no-underline lg:font-bold
lg:tracking-wide hover:bg-accent-1
lg:hover:bg-transparent hover:text-accent-8
focus:outline-none focus:bg-accent-1
focus:text-accent-8`,
{
underline:
!activeCategory?.navigationItem.data.contentForLanguage,
}
)}
>
<Link href={{ pathname: `/search` }}>
<a
onClick={(e) => handleClick(e, 'categories')}
className={
'block lg:inline-block px-4 py-2 lg:p-0 lg:my-2 lg:mx-4'
}
>
Всички категории
</a>
</Link>
</li>
{categories?.items.map((category) => (
<li
key={category.navigationItem._id}
className={cn(
`block text-sm leading-5 text-accent-4
hover:bg-accent-1 lg:hover:bg-transparent
hover:text-accent-8 focus:outline-none
focus:bg-accent-1 focus:text-accent-8`,
{
underline:
activeCategory?.navigationItem._id ===
category?.navigationItem._id,
}
)}
>
<Link
href={{
pathname: `/search${category?.navigationItem.data.url}`,
}}
>
<a
onClick={(e) => handleClick(e, 'categories')}
className={
'w-fit lg:inline-block px-4 py-2 lg:p-0 lg:my-2 lg:mx-4'
}
>
{category.navigationItem.data.contentForLanguage}
</a>
</Link>
</li>
))}
</ul>
</div>
</div>
</div>
</div>
)
}

export default CatalogCategories
1 change: 1 addition & 0 deletions components/catalog/CatalogCategories/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './CatalogCategories'
Loading

0 comments on commit 0f784b5

Please sign in to comment.