Skip to content

Commit

Permalink
Merge pull request #73 from damla/dev
Browse files Browse the repository at this point in the history
Refactor Done
  • Loading branch information
damla authored Feb 15, 2021
2 parents a988e41 + dba4b2b commit 9663161
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 52 deletions.
2 changes: 0 additions & 2 deletions .env.preview

This file was deleted.

8 changes: 4 additions & 4 deletions components/image-box/image-box.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,17 @@ export default function ImageBox ({
classNames(hero !== undefined ? styles.container_hero : styles.container, wider !== undefined && styles.container__wider)}
>
<Image
className={classNames(styles.image, styles.blur, isLoading ? styles.hide : undefined)}
className={classNames(styles.image, styles.blur, isLoading && styles.hide)}
src={lowQualitySrc}
alt={alt}
layout="fill"
objectFit={objectFit}
quality={1}
quality={10}
objectPosition={objectPosition}
/>
<Image
onLoad={ handleLoad }
className={classNames(styles.image, isLoading ? styles.hide : undefined)}
className={classNames(styles.image, isLoading && styles.hide)}
src={src}
alt={alt}
layout="fill"
Expand All @@ -63,7 +63,7 @@ export default function ImageBox ({
quality={quality}
objectPosition={objectPosition}
/>
<div className={classNames(styles.blackOverlay, isLoading || hero === undefined ? styles.hide : undefined)}></div>
<div className={classNames(styles.blackOverlay, (isLoading || hero === undefined) && styles.hide)}></div>
</div>
)
}
2 changes: 2 additions & 0 deletions interfaces/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ export interface AboutUsModel {
_id: ObjectID
lang: string
title: string
subtitle: string
paragraphs: string[]
}

export interface CatalogModel {
Expand Down
22 changes: 9 additions & 13 deletions pages/about-us/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import Paragraph from '../../components/paragraph/paragraph.component'

import styles from './about-us.module.scss'

import { getData } from '../../lib'
import { getData } from '../../utils/dbUtils'
import { CommonModel, AboutUsModel } from '../../interfaces/index'
import fs from 'fs'
import { getBase64Values } from '../../utils/imageUtils'
// import Grid from '../../components/grid/grid.component'

interface Props {
Expand All @@ -25,13 +25,7 @@ export const getStaticProps: GetStaticProps = async ({ locale = 'tr' }) => {
const pageData = await getData<AboutUsModel>('about-us', locale)

const images = ['about_us_hero']
const base64Values = []

for (const image of images) {
const val: string = fs.readFileSync(`public/assets/low-quality-images/${image}.jpg`, 'base64')
const res = `data:image/png;base64,${val}`
base64Values.push(res)
}
const base64Values: string[] = getBase64Values(images)

return {
props: {
Expand All @@ -45,7 +39,9 @@ export const getStaticProps: GetStaticProps = async ({ locale = 'tr' }) => {
export default function AboutUs ({
common,
page: {
title
title,
subtitle,
paragraphs
},
Base64Values
}: Props
Expand All @@ -70,13 +66,13 @@ export default function AboutUs ({
<Section relative>
<div className={styles.section_container}>
<h1 className={styles.h1}>{title}</h1>
<h3 className={styles.h3}>Karsal Örme Tekstil San. A.Ş., 1970’li yıllarda Trabzon’da peştemal işleri ile tekstile başlayan KÖKSAL ailesinin ikinci kuşak aile fertleri tarafından 1995 yılında İstanbul’da kurulmuştur.</h3>
<h3 className={styles.h3}>{subtitle}</h3>
<div className={styles.section_body}>
<Paragraph>
Karsal; 165 adet Meyer & Cie vb. markalı örme makinesi ve toplam 400 çalışanı ile üç iplik, iki iplik, süprem, ribana, interlog gibi hertürlü örgüyi yapabilecek altyapıya sahiptir. 35.000 m2 kapalı alanda faaliyet gösteren Karsal; yıllık ortalama 8.000 Ton (Sekizbin Ton) ham ve boyalı kumaş üretimi yapmaktadır. Karsal Örme Tekstil San. Tic. ve A. Ş., Ergene / Tekirdağ’ da faaliyet göstermektedir. Güçlü finansal yapısı ve entegre işletme olmasının verdiği güç ile karsal, müşteri talepleri doğrultusunda, iplik tedariki sonrası tüm işlemleri kendi işletmesi ve kendi sorumluluğunda yürüterek, müşterisine, boyanmış, kesime hazır kumaş olarak teslim etmektedir.
{paragraphs[0]}
</Paragraph>
<Paragraph>
Bir Karsal müşterisi, sadece kumaş numunesi veya seçimi yaptıktan sonra hiçbir işlemin sorumluluğu ve terminini takip etmek zorunda kalmadan faaliyet konusuna yoğunlaşabilmektedir. Bu nedenle Karsal üretimi kolaylaştırmaktadır. Karsal; Rusya, Hırvatistan, Bulgaristan, İtalya, Almanya, Portekiz, İspanya başta olmak üzere, birçok Avrupa ve Doğu Bloku ülkesine doğrudan ihracat yapmaktadır. Aileden gelen tekstil tecrübesi ile entegre bir sistemde üretimin yapılması, Karsal’a; üretilen kumaşların kalitesinin tüm sorumluluğunu üstlenebilmesini sağlamaktadır. Karsal; işinin profesyonelleri sayesinde müşterilerine, sağladığı kaliteli hammaddeyi, titiz bir işçilik ve düzenli ve hızlı sunumla müşteriye ulaştırmaktadır.
{paragraphs[1]}
</Paragraph>
</div>
{/* <Grid/> */}
Expand Down
2 changes: 1 addition & 1 deletion pages/catalog/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Layout from '../../components/layout/layout.component'

import './catalog.module.scss'

import { getData } from '../../lib'
import { getData } from '../../utils/dbUtils'
import { CommonModel, CatalogModel } from '../../interfaces/index'

interface Props {
Expand Down
12 changes: 3 additions & 9 deletions pages/contact/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import Layout from '../../components/layout/layout.component'
import Section from '../../components/section/section.component'
import ImageBox from '../../components/image-box/image-box.component'

import { getData } from '../../lib'
import { getData } from '../../utils/dbUtils'
import { CommonModel, ContactModel } from '../../interfaces/index'
import fs from 'fs'
import { getBase64Values } from '../../utils/imageUtils'

interface Props {
common: CommonModel
Expand All @@ -21,13 +21,7 @@ export const getStaticProps: GetStaticProps = async ({ locale = 'tr' }) => {
const pageData = await getData<ContactModel>('contact', locale)

const images = ['contact_us_hero']
const base64Values = []

for (const image of images) {
const val: string = fs.readFileSync(`public/assets/low-quality-images/${image}.jpg`, 'base64')
const res = `data:image/png;base64,${val}`
base64Values.push(res)
}
const base64Values: string[] = getBase64Values(images)

return {
props: {
Expand Down
12 changes: 3 additions & 9 deletions pages/factory/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import ImageBox from '../../components/image-box/image-box.component'

import './factory.module.scss'

import { getData } from '../../lib'
import { getData } from '../../utils/dbUtils'
import { CommonModel, FactoryModel } from '../../interfaces/index'
import fs from 'fs'
import { getBase64Values } from '../../utils/imageUtils'

interface Props {
common: CommonModel
Expand All @@ -23,13 +23,7 @@ export const getStaticProps: GetStaticProps = async ({ locale = 'tr' }) => {
const pageData = await getData<FactoryModel>('factory', locale)

const images = ['factory_hero']
const base64Values = []

for (const image of images) {
const val: string = fs.readFileSync(`public/assets/low-quality-images/${image}.jpg`, 'base64')
const res = `data:image/png;base64,${val}`
base64Values.push(res)
}
const base64Values: string[] = getBase64Values(images)

return {
props: {
Expand Down
12 changes: 3 additions & 9 deletions pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import CustomButton from '../components/custom-button/custom-button.component'
import Logo from '../components/logo/logo.component'

import { CommonModel, HomePageModel } from '../interfaces/index'
import { getData } from '../lib'
import { getData } from '../utils/dbUtils'
import { useMediaQuery } from 'react-responsive'
import fs from 'fs'
import { getBase64Values } from '../utils/imageUtils'

interface Props {
common: CommonModel
Expand All @@ -26,13 +26,7 @@ export const getStaticProps: GetStaticProps = async ({ locale = 'tr' }) => {
const pageData = await getData<HomePageModel>('home-page', locale)

const sections = ['section_1', 'section_2', 'section_3']
const base64Values = []

for (const section of sections) {
const val: string = fs.readFileSync(`public/assets/low-quality-images/${section}.jpg`, 'base64')
const res = `data:image/png;base64,${val}`
base64Values.push(res)
}
const base64Values: string[] = getBase64Values(sections)

return {
props: {
Expand Down
7 changes: 3 additions & 4 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
"pages/api/page-images/index.js",
"pages/api/page-images/[pid].js"
"**/*.tsx"
],
"exclude": [
"node_modules"
"node_modules",
"utils/dbUtils/mongodb.js"
]
}
2 changes: 1 addition & 1 deletion lib/index.ts → utils/dbUtils/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { connectToDatabase } from '../util/mongodb'
import { connectToDatabase } from './mongodb'

export async function getData<T> (page: string, lang: string): Promise<T> {
const { db } = await connectToDatabase()
Expand Down
File renamed without changes.
13 changes: 13 additions & 0 deletions utils/imageUtils/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import fs from 'fs'

export function getBase64Values (sections: string[]): string[] {
const base64Values: string[] = []

sections.forEach((item) => {
const val: string = fs.readFileSync(`public/assets/low-quality-images/${item}.jpg`, 'base64')
const res = `data:image/png;base64,${val}`
base64Values.push(res)
})

return base64Values
}

1 comment on commit 9663161

@vercel
Copy link

@vercel vercel bot commented on 9663161 Feb 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

Please sign in to comment.