-
-
onThemeChange('soho-light')}>
-
-
-
Soho Light
-
-
-
onThemeChange('soho-dark', true)}>
-
-
-
Soho Dark
-
-
-
onThemeChange('viva-light')}>
-
-
-
Viva Light
-
-
-
onThemeChange('viva-dark', true)}>
-
-
-
Viva Dark
-
-
-
onThemeChange('mira')}>
-
-
-
Mira
-
-
-
onThemeChange('nano')}>
-
-
-
Nano
-
+
+
+
+
+
+
Soho
+
+
changeTheme('soho')}
+ >
+
+
+
+
+
+
+
Viva
+
+
changeTheme('viva')}
+ >
+
+
+
+
+
+
-
PrimeOne Design - Legacy
-
-
-
onThemeChange('saga-blue')}>
-
-
-
Saga Blue
-
-
-
onThemeChange('saga-green')}>
-
-
-
Saga Green
-
-
-
onThemeChange('saga-orange')}>
-
-
-
Saga Orange
-
-
-
onThemeChange('saga-purple')}>
-
-
-
Saga Purple
-
-
-
onThemeChange('vela-blue', true)}>
-
-
-
Vela Blue
-
-
-
onThemeChange('vela-green', true)}>
-
-
-
Vela Green
-
-
-
onThemeChange('vela-orange', true)}>
-
-
-
Vela Orange
-
-
-
onThemeChange('vela-purple', true)}>
-
-
-
Vela Purple
-
-
-
onThemeChange('arya-blue', true)}>
-
-
-
Arya Blue
-
-
-
onThemeChange('arya-green', true)}>
-
-
-
Arya Green
-
-
-
onThemeChange('arya-orange', true)}>
-
-
-
Arya Orange
-
-
-
onThemeChange('arya-purple', true)}>
-
-
-
Arya Purple
-
+
+
+
+
+
+
Fluent
+
+
changeTheme('fluent-light')}
+ >
+
+
+
+
+
+
+
Mira
+
+
changeTheme('mira')}
+ >
+
+
+
+
+
+
+
Nano
+
+
changeTheme('nano')}
+ >
+
+
+
+
diff --git a/components/layout/layout.js b/components/layout/layout.js
index f19e155060..ea15928a3f 100644
--- a/components/layout/layout.js
+++ b/components/layout/layout.js
@@ -10,6 +10,7 @@ import Menu from './menu';
import Topbar from './topbar';
import { PrimeReactContext } from '../lib/api/PrimeReactContext';
import PrimeReact from '../lib/api/Api';
+import HeaderSection from '../../pages/landing/headersection';
export default function Layout(props) {
const [ripple, setRipple] = useState(true);
@@ -24,8 +25,8 @@ export default function Layout(props) {
'layout-news-active': props.newsActive,
'p-input-filled': (context && context.inputStyle === 'filled') || PrimeReact.inputStyle === 'filled',
'p-ripple-disabled': (context && context.ripple === false) || PrimeReact.ripple === false,
- 'layout-wrapper-dark': props.dark,
- 'layout-wrapper-light': !props.dark
+ 'layout-dark': props.dark,
+ 'layout-light': !props.dark
});
const maskClassName = classNames('layout-mask', {
'layout-mask-active': sidebarActive
@@ -75,6 +76,20 @@ export default function Layout(props) {
setConfigActive(true);
};
+ const toggleColorScheme = () => {
+ let newTheme;
+ let currentTheme = props.theme;
+
+ if (props.dark) {
+ newTheme = currentTheme.replace('dark', 'light');
+ } else {
+ if (currentTheme.includes('light') && currentTheme !== 'fluent-light') newTheme = currentTheme.replace('light', 'dark');
+ else newTheme = 'lara-dark-indigo'; //fallback
+ }
+
+ props.onThemeChange(newTheme, !props.dark);
+ };
+
useEffect(() => {
if (context) {
context.setRipple(ripple);
@@ -125,8 +140,8 @@ export default function Layout(props) {
{props.newsActive &&
}
-
-
+
+
+
+
-
- {props.children}
-
-
+
+
{props.children}
+
diff --git a/components/layout/menu.js b/components/layout/menu.js
index 82811dac7a..5429529d2d 100644
--- a/components/layout/menu.js
+++ b/components/layout/menu.js
@@ -1,10 +1,8 @@
-import Link from 'next/link';
import { useRouter } from 'next/router';
import React, { memo, useEffect } from 'react';
-import { Badge } from '../lib/badge/Badge';
-import { StyleClass } from '../lib/styleclass/StyleClass';
import { classNames } from '../lib/utils/Utils';
import MenuData from './menu.json';
+import MenuItem from './menuitem';
const Menu = memo((props) => {
const router = useRouter();
@@ -16,35 +14,6 @@ const Menu = memo((props) => {
return rootItem;
});
- const renderLink = (item) => {
- const { name, to, href } = item;
- const content = (
- <>
- {item.icon && (
-
-
-
- )}
- {name}
- {item.badge &&
}
- >
- );
-
- if (href) {
- return (
-
- {content}
-
- );
- } else {
- return (
-
-
{content}
-
- );
- }
- };
-
const scrollToActiveItem = () => {
const activeItem = document.querySelector('.router-link-active');
@@ -57,86 +26,16 @@ const Menu = memo((props) => {
scrollToActiveItem();
}, []);
- const renderChild = (menuitem, key) => {
- if (menuitem.children) {
- return (
-
- {menuitem.name}
-
- {menuitem.children.map((child, index) => {
- const link = renderLink(child);
-
- return {link} ;
- })}
-
-
- );
- } else {
- const link = renderLink(menuitem);
-
- return
{link} ;
- }
- };
-
- const renderRootMenuItemChildren = (menuitem, parentIndex) => {
- if (menuitem.children) {
- return (
-
-
{menuitem.children.map((item, index) => renderChild(item, parentIndex + '_' + index))}
-
- );
- }
-
- return null;
- };
-
- const renderRootItemButton = (menuitem) => {
- const btnRef = React.createRef();
-
- return (
-
-
-
-
-
- {menuitem.name}
-
-
-
- );
- };
-
- const renderRootMenuItems = () => {
- return (
- <>
- {menu &&
- menu.map((menuitem, index) => {
- const label = menuitem.children ? renderRootItemButton(menuitem, index) : renderLink(menuitem);
- const children = renderRootMenuItemChildren(menuitem, index);
-
- return (
-
- {label}
- {children}
-
- );
- })}
- >
- );
- };
-
- const menuItems = renderRootMenuItems();
const sidebarClassName = classNames('layout-sidebar', { active: props.active });
return (
-
-
-
-
-
- {menuItems}
+
+ {menu.map((item, index) => (
+
+ ))}
+
);
diff --git a/components/layout/menu.json b/components/layout/menu.json
index 58e79604b2..80c0fe1c23 100644
--- a/components/layout/menu.json
+++ b/components/layout/menu.json
@@ -493,7 +493,6 @@
{
"name": "Icons",
"icon": "pi pi-eye",
- "to": "/icons",
"children": [
{
"name": "Prime Icons",
diff --git a/components/layout/menuitem.js b/components/layout/menuitem.js
new file mode 100644
index 0000000000..13978f55b7
--- /dev/null
+++ b/components/layout/menuitem.js
@@ -0,0 +1,71 @@
+import React, { useRef } from 'react';
+import { Badge } from '../lib/badge/Badge';
+import Link from 'next/link';
+import { StyleClass } from '../lib/styleclass/StyleClass';
+import { classNames } from '../lib/utils/Utils';
+import { useRouter } from 'next/router';
+
+function MenuItem(props) {
+ const router = useRouter();
+ const { menuItem, root } = props;
+
+ const btnRef = useRef(null);
+
+ const isActiveRootmenuItem = (rootItem) => {
+ return rootItem.children && !rootItem.children.some((item) => item.to === router.pathname || (item.children && item.children.some((it) => it.to === router.pathname)));
+ };
+
+ return (
+
+ {menuItem.children && root && (
+
+
+
+
+
+ {menuItem.name}
+
+
+
+ )}
+ {menuItem?.href && (
+
+
+ {menuItem?.icon && root && (
+
+
+
+ )}
+ {menuItem?.name}
+ {menuItem?.badge && }
+
+
+ )}
+ {menuItem?.to && (
+
+
+ {menuItem?.icon && root && (
+
+
+
+ )}
+ {menuItem?.name}
+ {menuItem?.badge && }
+
+
+ )}
+ {!root && menuItem.children && {menuItem?.name} }
+ {menuItem?.children && (
+
+
+ {menuItem.children.map((item, index) => (
+
+ ))}
+
+
+ )}
+
+ );
+}
+
+export default MenuItem;
diff --git a/components/layout/topbar.js b/components/layout/topbar.js
index 75c8f03e49..f605541659 100644
--- a/components/layout/topbar.js
+++ b/components/layout/topbar.js
@@ -2,6 +2,8 @@ import { DocSearch } from '@docsearch/react';
import { useEffect, useRef } from 'react';
import pkg from '../../package.json';
import { StyleClass } from '../lib/styleclass/StyleClass';
+import Link from 'next/link';
+import { classNames } from '../lib/utils/Utils';
export default function Topbar(props) {
const versionsRef = useRef(null);
@@ -96,22 +98,79 @@ export default function Topbar(props) {
};
}, []);
+ const toggleDarkMode = () => {
+ props.darkModeSwitch();
+ };
+
return (
-
-
-
-
+
-
+
+
+
@@ -121,7 +180,7 @@ export default function Topbar(props) {
href="https://discord.gg/gzKFYnpmCY"
target="_blank"
rel="noopener noreferrer"
- className="flex px-link border-1 border-solid w-2rem h-2rem surface-border border-round surface-card align-items-center justify-content-center transition-all transition-duration-300 hover:border-primary"
+ className="flex flex-shrink-0 px-link border-1 border-solid w-2rem h-2rem surface-border border-round surface-card align-items-center justify-content-center transition-all transition-duration-300 hover:border-primary"
>
@@ -131,23 +190,34 @@ export default function Topbar(props) {
href="https://github.com/orgs/primefaces/discussions"
target="_blank"
rel="noopener noreferrer"
- className="flex px-link border-1 border-solid w-2rem h-2rem surface-border border-round surface-card align-items-center justify-content-center transition-all transition-duration-300 hover:border-primary"
+ className="flex flex-shrink-0 px-link border-1 border-solid w-2rem h-2rem surface-border border-round surface-card align-items-center justify-content-center transition-all transition-duration-300 hover:border-primary"
>
-
-
+
+
+ {props.showConfigurator && (
+
+
+
+
+
+ )}
{versions && versions.length ? versions[0].version : ''}
@@ -168,6 +238,19 @@ export default function Topbar(props) {
+ {props.showMenuButton && (
+
+
+
+
+
+ )}
diff --git a/pages/index.js b/pages/index.js
index 3fdc389cd9..6ba95873fa 100644
--- a/pages/index.js
+++ b/pages/index.js
@@ -3,32 +3,37 @@ import { useEffect, useState } from 'react';
import { classNames } from '../components/lib/utils/Utils';
import NewsSection from '../components/news/newssection';
import BlockSection from './landing/blocksection';
-import ComponentSection from './landing/componentsection';
-import DesignerSection from './landing/designersection';
import FeaturesSection from './landing/featuressection';
import FooterSection from './landing/footersection';
-import HeaderSection from './landing/headersection';
import HeroSection from './landing/herosection';
import TemplateSection from './landing/templatesection';
import ThemeSection from './landing/themesection';
import UsersSection from './landing/userssection';
+import Topbar from '../components/layout/topbar';
export default function Home(props) {
const [tableTheme, setTableTheme] = useState('lara-light-indigo');
- const rootClassName = classNames('landing', { 'landing-light': !props.dark, 'landing-dark': props.dark, 'landing-news-active': props.newsActive });
-
- const toggleColorScheme = () => {
- const darkMode = !props.dark;
- const newTheme = darkMode ? 'lara-dark-indigo' : 'lara-light-indigo';
-
- props.onThemeChange(newTheme, darkMode);
- };
+ const landingClass = classNames('landing', { 'layout-light': !props.dark, 'layout-dark': props.dark, 'layout-news-active': props.newsActive });
const changeTableTheme = (newTheme) => {
props.onTableThemeChange(tableTheme, newTheme);
setTableTheme(newTheme);
};
+ const onDarkModeToggle = () => {
+ let newTheme;
+ let currentTheme = props.theme;
+
+ if (props.dark) {
+ newTheme = currentTheme.replace('dark', 'light');
+ } else {
+ if (currentTheme.includes('light') && currentTheme !== 'fluent-light') newTheme = currentTheme.replace('light', 'dark');
+ else newTheme = 'lara-dark-indigo'; //fallback
+ }
+
+ props.onThemeChange(newTheme, !props.dark);
+ };
+
useEffect(() => {
const newTheme = props.dark ? tableTheme.replace('light', 'dark') : tableTheme.replace('dark', 'light');
@@ -36,7 +41,7 @@ export default function Home(props) {
}, [props.dark]); // eslint-disable-line react-hooks/exhaustive-deps
return (
-