Skip to content

Commit

Permalink
Refactor utils paths & names (#122)
Browse files Browse the repository at this point in the history
* Rename `getNoionColor` function

* Remove unused `getAllUrls`

* Update previews module name

* Move `IsetSans` to `styles/fonts` from utils

* Rename `textParser` to `getNotionContentItems`
  • Loading branch information
sashachabin authored Dec 21, 2023
1 parent 4da39a2 commit 90d1496
Show file tree
Hide file tree
Showing 14 changed files with 40 additions and 65 deletions.
6 changes: 2 additions & 4 deletions components/NotionTypes/Callout/Callout.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import React from 'react'
import Image from 'next/image'

import { getTextContent } from '../../../utils/textParser'

import { getTextContent } from '../../../utils/getNotionContentItems'
import { getNotionColor } from '../../../utils/getNotionColor'
import styles from './Callout.module.css'
import { getNotionColor } from '../../../utils/colors'

export const Callout = ({ columnItem }) => {
const iconUrl = columnItem?.content?.icon?.external?.url
Expand Down
4 changes: 1 addition & 3 deletions components/NotionTypes/Headings/Headings.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import React from 'react'

import { getHeaderContent } from '../../../utils/textParser'

import { getHeaderContent } from '../../../utils/getNotionContentItems'
import styles from './Headings.module.css'

export function H1({ columnItem }) {
Expand Down
3 changes: 1 addition & 2 deletions components/NotionTypes/Lists/Ordered/Ordered.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react'

import { getTextContent } from '../../../../utils/textParser'
import { getTextContent } from '../../../../utils/getNotionContentItems'
import styles from './ordered.module.css'

export function OrderedList({ columnItem }) {
Expand Down
2 changes: 1 addition & 1 deletion components/NotionTypes/Lists/Unordered/Unordered.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'
import { getTextContent } from '../../../../utils/textParser'
import { getTextContent } from '../../../../utils/getNotionContentItems'
import styles from './unordered.module.css'

function UnorderedList({ columnItem }) {
Expand Down
2 changes: 0 additions & 2 deletions components/NotionTypes/Text/Code/Code.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import React from 'react'

// import getTextContent from '../../../../utils/notionTypeParser/textParser'
import styles from './code.module.css'

export default function Code({ columnItem }) {
Expand Down
3 changes: 1 addition & 2 deletions components/NotionTypes/Text/Paragraph/Paragraph.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react'

import { getTextContent } from '../../../../utils/getNotionContentItems'
import styles from './paragraph.module.css'
import { getTextContent } from '../../../../utils/textParser'

function Paragraph({ columnItem }) {
const textContent = getTextContent(columnItem, true)
Expand Down
4 changes: 2 additions & 2 deletions pages/_app.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createContext } from 'react'
import Head from 'next/head'
import { isetSansFont } from '../utils/font'
import { IsetSans } from '../styles/fonts/IsetSans'

import '../styles/globals.css'
import 'ekb/style.css'
Expand All @@ -15,7 +15,7 @@ function MyApp({ Component, pageProps }) {
<title>Городские руководства</title>
</Head>

<main className={isetSansFont.className}>
<main className={IsetSans.className}>
<Component {...pageProps} />
</main>
</>
Expand Down
4 changes: 2 additions & 2 deletions pages/index.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react'
import { getTree } from '../api/apiPage'
import parseManualsPreview from '../utils/manualsPreviewParser'
import getManualsPreviews from '../utils/getManualsPreviews'
import MainPage from '../components/MainPage/MainPage'

export default function Home({ manualsPreview }) {
Expand All @@ -12,7 +12,7 @@ export async function getServerSideProps() {

return {
props: {
manualsPreview: parseManualsPreview(tree),
manualsPreview: getManualsPreviews(tree),
},
}
}
27 changes: 27 additions & 0 deletions styles/fonts/IsetSans.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import localFont from 'next/font/local'

export const IsetSans = localFont({
src: [
{
path: 'IsetSans-Light.woff2',
weight: '300',
},
{
path: 'IsetSans-Medium.woff2',
weight: '500',
},
{
path: 'IsetSans-SemiBold.woff2',
weight: '600',
},
{
path: 'IsetSans-Regular.woff2',
weight: '400',
},
{
path: 'IsetSans-Regular-Italic.woff2',
weight: '400',
style: 'italic',
},
],
})
27 changes: 0 additions & 27 deletions utils/font.js

This file was deleted.

15 changes: 0 additions & 15 deletions utils/getAllUrls.js

This file was deleted.

4 changes: 2 additions & 2 deletions utils/manualsPreviewParser.js → utils/getManualsPreviews.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import t from './typograf'
import { MANUALS_HIDDEN } from '../consts/manuals'
import { API_HOST } from '../consts/endpoints'

function parseManualsPreview(tree) {
function getManualsPreviews(tree) {
// TODO Remove hard-code after back-end feature https://github.com/ekaterinburgdev/guides-api/issues/10
const manualsVisible = tree.children.filter((manual) => {
return !MANUALS_HIDDEN.includes(manual?.properties?.pageUrl?.url)
Expand Down Expand Up @@ -39,4 +39,4 @@ function parseManualsPreview(tree) {
})
}

export default parseManualsPreview
export default getManualsPreviews
File renamed without changes.
4 changes: 1 addition & 3 deletions utils/textParser.jsx → utils/getNotionContentItems.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import React from 'react'

import { getNotionColor } from './colors'

import t from './typograf'
import { getNotionColor } from './getNotionColor'

export const getHeaderContent = (item) =>
item.content.text.map((par) => {
Expand Down

0 comments on commit 90d1496

Please sign in to comment.