Skip to content

Commit

Permalink
Refactored to use PrimeFlex v4 theming
Browse files Browse the repository at this point in the history
  • Loading branch information
cagataycivici committed Aug 26, 2023
1 parent 35a8708 commit bb24bda
Show file tree
Hide file tree
Showing 14 changed files with 40 additions and 54 deletions.
5 changes: 0 additions & 5 deletions components/layout/appcontentcontext.js

This file was deleted.

30 changes: 8 additions & 22 deletions components/layout/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { useRouter } from 'next/router';
import { classNames } from 'primereact/utils';
import { useEffect, useState } from 'react';
import NewsSection from '../news/newssection';
import AppContentContext from './appcontentcontext';
import Footer from './footer';
import Menu from './menu';
import Topbar from './topbar';
Expand All @@ -12,11 +11,6 @@ export default function Layout(props) {
const [sidebarActive, setSidebarActive] = useState(false);
const router = useRouter();

const wrapperClassName = classNames('layout-wrapper', {
'layout-wrapper-dark': props.dark,
'layout-wrapper-light': !props.dark,
'layout-news-active': props.newsActive
});
const maskClassName = classNames('layout-mask', {
'layout-mask-active': sidebarActive
});
Expand Down Expand Up @@ -51,9 +45,9 @@ export default function Layout(props) {
}, [router]);

return (
<div className={wrapperClassName}>
<div className="layout-wrapper">
<Head>
<title>PrimeFlex - Utility-First CSS Library</title>
<title>PrimeFlex - Utility First CSS Library</title>
<meta charSet="UTF-8" />
<meta name="description" content="PrimeFlex is a utility-first CSS library." />
<meta name="robots" content="index, follow" />
Expand All @@ -63,7 +57,7 @@ export default function Layout(props) {
<meta name="twitter:title" content="PrimeFlex | Utility-First CSS Library" />
<meta name="twitter:description" content="PrimeFlex is a utility-first CSS library." />
<meta property="og:type" content="website"></meta>
<meta property="og:title" content="PrimeFlex - Utility-First CSS Library"></meta>
<meta property="og:title" content="PrimeFlex - Utility First CSS Library"></meta>
<meta property="og:url" content="https://primeflex.org"></meta>
<meta property="og:description" content="PrimeFlex is a utility-first CSS library." />
<meta property="og:image" content="https://www.primefaces.org/static/social/primeflex-preview.jpg"></meta>
Expand All @@ -73,20 +67,12 @@ export default function Layout(props) {
{props.newsActive && <NewsSection announcement={props.announcement} onClose={props.onNewsClose} />}
<Topbar dark={props.dark} onMenuButtonClick={onMenuButtonClick} onToggleColorScheme={toggleColorScheme} />
<Menu active={sidebarActive} darkTheme={props.dark} />
<AppContentContext.Provider
value={{
ripple: true,
inputStyle: 'outlined',
darkTheme: props.dark
}}
>
<div className="layout-content">
<div className="layout-content-inner">
{props.children}
<Footer></Footer>
</div>
<div className="layout-content">
<div className="layout-content-inner">
{props.children}
<Footer></Footer>
</div>
</AppContentContext.Provider>
</div>
<div className={maskClassName} onClick={onMaskClick}></div>
</div>
);
Expand Down
19 changes: 14 additions & 5 deletions pages/_app.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import '@docsearch/css';
import { DomHandler } from 'primereact/utils';
import { classNames } from 'primereact/utils';
import { useEffect, useRef, useState } from 'react';
import Layout from '../components/layout/layout';
import AnnouncementData from '../data/news.json';
Expand All @@ -12,6 +12,7 @@ export default function MyApp({ Component }) {
const [newsActive, setNewsActive] = useState(false);
const announcement = useRef(AnnouncementData);
const storageKey = 'primeflex-news';
const theme = dark ? 'primeone-dark' : 'primeone-light';

const props = {
dark: dark,
Expand Down Expand Up @@ -55,21 +56,29 @@ export default function MyApp({ Component }) {
}
}, []);

useEffect(() => {
/*useEffect(() => {
DomHandler.addClass(document.body, dark ? 'layout-dark' : 'layout-light');
return () => {
DomHandler.removeMultipleClasses(document.body, 'layout-dark layout-light');
};
}, [dark]);
}, [dark]);*/

let content;

if (Component.getLayout) {
return Component.getLayout(<Component {...props} />);
content = Component.getLayout(<Component {...props} />);
} else {
return (
content = (
<Layout {...props}>
<Component {...props} />
</Layout>
);
}

return (
<div className={classNames('app', { 'app-news-active': props.newsActive })} data-pf-theme={theme}>
{content}
</div>
);
}
9 changes: 3 additions & 6 deletions pages/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Head from 'next/head';
import { classNames } from 'primereact/utils';
import NewsSection from '../components/news/newssection';
import AnimationsSection from './landing/animationssection';
import BlocksSection from './landing/blockssection';
Expand All @@ -12,16 +11,14 @@ import StyleSection from './landing/stylesection';
import UsersSection from './landing/userssection';

export default function Home(props) {
const rootClassName = classNames('landing', { 'landing-light': !props.dark, 'landing-dark': props.dark, 'landing-news-active': props.newsActive });

const toggleColorScheme = () => {
props.onThemeChange(!props.dark);
};

return (
<div className={rootClassName}>
<div className="landing">
<Head>
<title>PrimeFlex - Utility-First CSS Library</title>
<title>PrimeFlex - Utility First CSS Library</title>
<meta charSet="UTF-8" />
<meta name="description" content="PrimeFlex is a utility-first CSS library." />
<meta name="robots" content="index, follow" />
Expand All @@ -31,7 +28,7 @@ export default function Home(props) {
<meta name="twitter:title" content="PrimeFlex | Utility-First CSS Library" />
<meta name="twitter:description" content="PrimeFlex is a utility-first CSS library." />
<meta property="og:type" content="website"></meta>
<meta property="og:title" content="PrimeFlex - Utility-First CSS Library"></meta>
<meta property="og:title" content="PrimeFlex - Utility First CSS Library"></meta>
<meta property="og:url" content="https://primeflex.org"></meta>
<meta property="og:description" content="PrimeFlex is a utility-first CSS library." />
<meta property="og:image" content="https://www.primefaces.org/static/social/primeflex-preview.jpg"></meta>
Expand Down
4 changes: 2 additions & 2 deletions styles/layout/_code.scss
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ div.code-toolbar > .toolbar > .toolbar-item > span:focus {
text-decoration: none;
}

.layout-wrapper-dark {
[data-pf-theme="primeone-dark"] {
pre[class*="language-"] {
code {
.token {
Expand Down Expand Up @@ -331,7 +331,7 @@ div.code-toolbar > .toolbar > .toolbar-item > span:focus {
}
}

.layout-wrapper-light {
[data-pf-theme="primeone-light"] {
pre[class*="language-"] {
code {
.token {
Expand Down
5 changes: 3 additions & 2 deletions styles/layout/_doc.scss
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,8 @@
}
}
}
.layout-wrapper-light {

[data-pf-theme="primeone-light"] {
.doc-section-description {
> p {
i {
Expand All @@ -320,7 +321,7 @@
}
}

.layout-wrapper-dark {
[data-pf-theme="primeone-dark"] {
.doc-section-description {
> p {
i {
Expand Down
2 changes: 1 addition & 1 deletion styles/layout/_layout_dark.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.layout-dark {
[data-pf-theme="primeone-dark"] {
--surface-a: #00031a;
--surface-b: #191c31;
--surface-c: #333548;
Expand Down
2 changes: 1 addition & 1 deletion styles/layout/_layout_light.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.layout-light {
[data-pf-theme="primeone-light"] {
--surface-a: #ffffff;
--surface-b: #efefef;
--surface-c: #e9ecef;
Expand Down
2 changes: 1 addition & 1 deletion styles/layout/_layout_wrapper_dark.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.layout-wrapper-dark {
[data-pf-theme="primeone-dark"] {
--body-bg: rgb(8, 19, 37);
--body-bg-image: url("https://www.primefaces.org/cdn/primeflex/images/headerfx.png");
--menu-bg: rgb(8, 19, 37);
Expand Down
2 changes: 1 addition & 1 deletion styles/layout/_layout_wrapper_light.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.layout-wrapper-light {
[data-pf-theme="primeone-light"] {
--body-bg: #f6f7f9;
--body-bg-image: url("https://www.primefaces.org/cdn/primeflex/images/headerfxlight.png");
--menu-bg: #f6f7f9;
Expand Down
6 changes: 2 additions & 4 deletions styles/layout/_news.scss
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,11 @@
}
}

.landing-news-active {
.app-news-active {
.landing-header-section {
padding-top: 3.5rem;
}
}

.layout-news-active {
.layout-sidebar,
.layout-topbar,
.layout-config {
Expand All @@ -73,4 +71,4 @@
.doc-table tbody td > i {
scroll-margin-top: 8.5rem;
}
}
}
2 changes: 1 addition & 1 deletion styles/layout/landing/_dark.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.landing-dark {
[data-pf-theme="primeone-dark"] {
--landing-body-bg: #00031a;
--landing-text-color: #c9c9c9;
--landing-border: 1px solid rgba(255, 255, 255, 0.1);
Expand Down
2 changes: 1 addition & 1 deletion styles/layout/landing/_light.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.landing-light {
[data-pf-theme="primeone-light"] {
--landing-body-bg: #fff;
--landing-text-color: #333333;
--landing-border: 1px solid rgba(0, 0, 0, 0.1);
Expand Down
4 changes: 2 additions & 2 deletions styles/prism.scss
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ div.code-toolbar > .toolbar > .toolbar-item > span:focus {
text-decoration: none;
}

.layout-wrapper-dark {
[data-pf-theme="primeone-dark"] {
pre[class*="language-"] {
position: relative;
background: transparent !important;
Expand Down Expand Up @@ -373,7 +373,7 @@ div.code-toolbar > .toolbar > .toolbar-item > span:focus {
}
}

.layout-wrapper-light {
[data-pf-theme="primeone-light"] {
pre[class*="language-"] {
position: relative;
background: transparent !important;
Expand Down

0 comments on commit bb24bda

Please sign in to comment.