Djordje Mitrovic 2 лет назад
Родитель
Сommit
7cbb5ab3e3

+ 13
- 3
src/components/Header/Header.js Просмотреть файл

import React from "react"; import React from "react";
import PropTypes from "prop-types"; import PropTypes from "prop-types";
import { HeaderContainer } from "./Header.styled";
import { HeaderContainer, HeaderSideContainer } from "./Header.styled";
import { useSelector } from "react-redux"; import { useSelector } from "react-redux";
import { selectBreadcrumbs } from "features/app/appSlice"; import { selectBreadcrumbs } from "features/app/appSlice";
import { selectCurrentUser } from "features/auth/authSlice"; import { selectCurrentUser } from "features/auth/authSlice";
import HeaderNavigation from "./HeaderNavigation/HeaderNavigation"; import HeaderNavigation from "./HeaderNavigation/HeaderNavigation";
import Logo from "components/Logo/Logo";
import { NavLink } from "react-router-dom";
import { PAGES } from "constants/pages";
import HeaderProfileBar from "./HeaderProfileBar/HeaderProfileBar";


const Header = () => { const Header = () => {
const breadcrumbs = useSelector(selectBreadcrumbs); const breadcrumbs = useSelector(selectBreadcrumbs);
const user = useSelector(selectCurrentUser); const user = useSelector(selectCurrentUser);
console.log(user); console.log(user);
console.log(breadcrumbs); console.log(breadcrumbs);
console.log(Logo);
return ( return (
<HeaderContainer> <HeaderContainer>
<HeaderNavigation />
<div>brate</div>
<HeaderSideContainer>
<Logo as={NavLink} to={PAGES.BASE.route} />
{user && <HeaderNavigation />}
</HeaderSideContainer>
<HeaderSideContainer>
<HeaderProfileBar />
</HeaderSideContainer>
</HeaderContainer> </HeaderContainer>
); );
}; };

+ 10
- 4
src/components/Header/Header.styled.js Просмотреть файл

import { Box } from "@mui/material"; import { Box } from "@mui/material";
import { themeToUse2 } from "hooks/useToggleColorMode";
import styled from "styled-components"; import styled from "styled-components";
import selectedTheme from "themes";


export const HeaderContainer = styled(Box)` export const HeaderContainer = styled(Box)`
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
padding: 0 148px;
width: 100vw;
padding: 0 24px;
width: 100%;
height: 72px; height: 72px;
background-color: ${selectedTheme.colors.primaryLight};
background-color: ${themeToUse2.palette.primaryDark};
`;
export const HeaderSideContainer = styled(Box)`
display: flex;
gap: 24px;
height: 100%;
align-items: center;
`; `;

+ 11
- 10
src/components/Header/HeaderNavigation/HeaderNavigationItem/HeaderNavigationItem.styled.js Просмотреть файл

import styled from "styled-components"; import styled from "styled-components";
import selectedTheme from "themes"; import selectedTheme from "themes";


export const HeaderNavigationItemIconContainer = styled(Box)``;
export const HeaderNavigationItemIconTitle = styled(Box)`
font-size: 14px;
line-height: 20px;
font-weight: ${(props) => props?.$isActive && 600};
color: white;
font-weight: 500;
`;

export const HeaderNavigationItemContainer = styled(NavLink)` export const HeaderNavigationItemContainer = styled(NavLink)`
display: flex; display: flex;
justify-content: center; justify-content: center;
height: 100%; height: 100%;
transition-duration: 0.1s; transition-duration: 0.1s;
&:hover { &:hover {
background-color: ${selectedTheme.colors.primaryLightLighter};
background-color: ${selectedTheme.colors.primaryLighter};
} }
&[aria-checked=true] ${HeaderNavigationItemIconTitle} {
&[aria-checked="true"] ${HeaderNavigationItemIconTitle} {
font-weight: 700; font-weight: 700;
} }
`; `;
export const HeaderNavigationItemIconContainer = styled(Box)``;
export const HeaderNavigationItemIconTitle = styled(Box)`
font-size: 14px;
line-height: 20px;
font-weight: ${(props) => props?.$isActive && 600};
color: white;
font-weight: 500;
`;

+ 15
- 0
src/components/Header/HeaderProfileBar/HeaderNotifications/HeaderNotifications.js Просмотреть файл

import React from "react";
import PropTypes from "prop-types";
import { HeaderNotificationsContainer } from "./HeaderNotifications.styled";

const HeaderNotifications = () => {
return (
<HeaderNotificationsContainer>notifications</HeaderNotificationsContainer>
);
};

HeaderNotifications.propTypes = {
children: PropTypes.node,
};

export default HeaderNotifications;

+ 4
- 0
src/components/Header/HeaderProfileBar/HeaderNotifications/HeaderNotifications.styled.js Просмотреть файл

import { Box } from "@mui/material";
import styled from "styled-components";

export const HeaderNotificationsContainer = styled(Box)``

+ 13
- 0
src/components/Header/HeaderProfileBar/HeaderProfile/HeaderProfile.js Просмотреть файл

import React from "react";
import PropTypes from "prop-types";
import { HeaderProfileContainer } from "./HeaderProfile.styled";

const HeaderProfile = () => {
return <HeaderProfileContainer>profile</HeaderProfileContainer>;
};

HeaderProfile.propTypes = {
children: PropTypes.node,
};

export default HeaderProfile;

+ 4
- 0
src/components/Header/HeaderProfileBar/HeaderProfile/HeaderProfile.styled.js Просмотреть файл

import { Box } from "@mui/material";
import styled from "styled-components";

export const HeaderProfileContainer = styled(Box)``

+ 22
- 0
src/components/Header/HeaderProfileBar/HeaderProfileBar.js Просмотреть файл

import React from "react";
import PropTypes from "prop-types";
import { HeaderProfileBarContainer } from "./HeaderProfileBar.styled";
import HeaderThemeChooser from "./HeaderThemeChooser/HeaderThemeChooser";
import HeaderNotifications from "./HeaderNotifications/HeaderNotifications";
import HeaderProfile from "./HeaderProfile/HeaderProfile";

const HeaderProfileBar = () => {
return (
<HeaderProfileBarContainer>
<HeaderThemeChooser />
<HeaderNotifications />
<HeaderProfile />
</HeaderProfileBarContainer>
);
};

HeaderProfileBar.propTypes = {
children: PropTypes.node,
};

export default HeaderProfileBar;

+ 8
- 0
src/components/Header/HeaderProfileBar/HeaderProfileBar.styled.js Просмотреть файл

import { Box } from "@mui/material";
import styled from "styled-components";

export const HeaderProfileBarContainer = styled(Box)`
display: flex;
gap: 24px;
align-items: center;
`

+ 26
- 0
src/components/Header/HeaderProfileBar/HeaderThemeChooser/HeaderThemeChooser.js Просмотреть файл

import React from "react";
import PropTypes from "prop-types";
import { HeaderThemeChooserContainer } from "./HeaderThemeChooser.styled";
import DarkModeIcon from "@mui/icons-material/DarkMode";
import useToggleColorMode, { themeToUse2 } from "hooks/useToggleColorMode";

const HeaderThemeChooser = () => {
const [toggleColorMode] = useToggleColorMode();

console.log(themeToUse2);

const handleChangeTheme = () => {
toggleColorMode();
}
return (
<HeaderThemeChooserContainer onClick={handleChangeTheme}>
<DarkModeIcon />
</HeaderThemeChooserContainer>
);
};

HeaderThemeChooser.propTypes = {
children: PropTypes.node,
};

export default HeaderThemeChooser;

+ 4
- 0
src/components/Header/HeaderProfileBar/HeaderThemeChooser/HeaderThemeChooser.styled.js Просмотреть файл

import { Box } from "@mui/material";
import styled from "styled-components";

export const HeaderThemeChooserContainer = styled(Box)``

+ 24
- 0
src/components/Logo/Logo.js Просмотреть файл

import React, { forwardRef } from "react";
import PropTypes from "prop-types";
import { LogoContainer } from "./Logo.styled";
//Import logo

const Logo = forwardRef((props, ref) => {
return (
<LogoContainer
{...props}
ref={ref}
// src={LogoImage}
>
Logo
</LogoContainer>
);
});

Logo.displayName = "Logo";

Logo.propTypes = {
children: PropTypes.node,
};

export default Logo;

+ 7
- 0
src/components/Logo/Logo.styled.js Просмотреть файл

import styled from "styled-components";
// Replace with styled.img when there is logo
export const LogoContainer = styled.div`
text-decoration: none;
cursor: pointer;
color: white;
`;

+ 22
- 22
src/hooks/useToggleColorMode.js Просмотреть файл

authScopeSetHelper, authScopeSetHelper,
authScopeStringGetHelper, authScopeStringGetHelper,
} from "util/authScopeHelpers"; } from "util/authScopeHelpers";
import selectedTheme from "themes";
import selectedTheme, { reinitializeTheme } from "themes";
import { primaryThemeColors } from "themes/primaryTheme/primaryThemeColors";
import { secondaryThemeColors } from "themes/secondaryTheme/secondaryThemeColors";

var themeToUse = {
palette: {
primary: "white",
},
};


const useToggleColorMode = () => { const useToggleColorMode = () => {
const currentColorMode = authScopeStringGetHelper("colorMode") || "light"; const currentColorMode = authScopeStringGetHelper("colorMode") || "light";
authScopeSetHelper("colorMode", nextMode); authScopeSetHelper("colorMode", nextMode);
}; };


const theme = useMemo(
() =>
createTheme({
palette: {
mode,
primary: {
main:
mode === "light"
? selectedTheme.colors.primaryLight
: selectedTheme.colors.primaryDark,
},
secondary: {
main:
mode === "light"
? selectedTheme.colors.secondaryLight
: selectedTheme.colors.secondaryDark,
},
},
}),
[mode]
);
const theme = useMemo(() => {
reinitializeTheme();
themeToUse = createTheme({
palette: {
mode,
...(mode === "light" ? primaryThemeColors : secondaryThemeColors),
},
});
return themeToUse;
}, [mode]);
console.log(selectedTheme);


return [toggleColorMode, theme]; return [toggleColorMode, theme];
}; };


export const themeToUse2 = getTheme;

export default useToggleColorMode; export default useToggleColorMode;

+ 19
- 7
src/themes/index.js Просмотреть файл

import { authScopeStringGetHelper } from "util/authScopeHelpers";
import primary from "./primaryTheme/primaryTheme"; import primary from "./primaryTheme/primaryTheme";
import secondary from "./secondaryTheme/secondaryTheme";


let selectedThemeNumber = 0;


const getTheme = () => {
if (selectedThemeNumber === 0) {
return {...primary}
}
export const getTheme = () => {
let selectedThemeStorage = authScopeStringGetHelper("colorMode");
console.log(selectedThemeStorage);
if (selectedThemeStorage === "light") {
return { ...primary };
}
if (selectedThemeStorage === "dark") {
return { ...secondary };
}
};

let selectedTheme = getTheme();

export const reinitializeTheme = () => {
selectedTheme = getTheme();
} }


const selectedTheme = getTheme();
export default selectedTheme;


export default selectedTheme;
npm i @ckeditor/ckeditor5-dev-utils @ckeditor/ckeditor5-theme-lark @ckeditor/ckeditor5-react @ckeditor/ckeditor5-editor-classic @ckeditor/ckeditor5-essentials @ckeditor/ckeditor5-paragraph @ckeditor/ckeditor5-basic-styles

+ 4
- 7
src/themes/primaryTheme/primaryThemeColors.js Просмотреть файл

export const primaryThemeColors = { export const primaryThemeColors = {
primaryLight: "#673ab7",
primaryLightLighter: "#845ccb",
primaryDark: "#009688",
secondaryLight: "#212121",
secondaryDark: "#f5f5f5",
};
primaryDark: "#673ab7",
primaryLighter: "#845ccb",
secondaryDark: "#212121",
};

+ 7
- 0
src/themes/secondaryTheme/secondaryTheme.js Просмотреть файл

import { secondaryThemeColors } from "./secondaryThemeColors";

const secondary = {
colors: secondaryThemeColors,
};

export default secondary;

+ 4
- 0
src/themes/secondaryTheme/secondaryThemeColors.js Просмотреть файл

export const secondaryThemeColors = {
primaryDark: "#009688",
secondaryDark: "#f5f5f5",
};

Загрузка…
Отмена
Сохранить