mirror of
https://github.com/IgnatZakalinsky/home-works.git
synced 2025-12-17 04:49:25 +00:00
final ref hw12
This commit is contained in:
@@ -20,24 +20,3 @@ code {
|
|||||||
monospace;
|
monospace;
|
||||||
}
|
}
|
||||||
|
|
||||||
[data-theme='1'] {
|
|
||||||
|
|
||||||
--background: #FFFFFF;
|
|
||||||
--color: #000000;
|
|
||||||
}
|
|
||||||
|
|
||||||
[data-theme='2'] {
|
|
||||||
--color: #000000;
|
|
||||||
--background: #DDEEFF;
|
|
||||||
}
|
|
||||||
|
|
||||||
[data-theme='3'] {
|
|
||||||
--color: #FFFFFF;
|
|
||||||
--background: #212A34;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
html {
|
|
||||||
background-color: var(--background);
|
|
||||||
color: var(--color);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -7,17 +7,8 @@ import HW4 from '../s2-homeworks/hw04/HW4'
|
|||||||
import HW5 from '../s2-homeworks/hw05/HW5'
|
import HW5 from '../s2-homeworks/hw05/HW5'
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
// для дз 12
|
|
||||||
// const themeId = useSelector((state: any) => state.theme.themeId)
|
|
||||||
// useEffect(() => {
|
|
||||||
// document.documentElement.dataset.theme = themeId
|
|
||||||
// }, [themeId])
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div className={s.App}>
|
||||||
className={s.App}
|
|
||||||
// data-theme={themeId} // для дз 12
|
|
||||||
>
|
|
||||||
{/*<HW1/>*/}
|
{/*<HW1/>*/}
|
||||||
{/*раскомментировать по ходу выполнения*/}
|
{/*раскомментировать по ходу выполнения*/}
|
||||||
{/*<HW2/>*/}
|
{/*<HW2/>*/}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import HW10 from '../../hw10/HW10'
|
import HW10 from '../../hw10/HW10'
|
||||||
import HW11 from '../../hw11/HW11'
|
import HW11 from '../../hw11/HW11'
|
||||||
// import HW12 from '../../hw12/HW12'
|
import HW12 from '../../hw12/HW12'
|
||||||
// import HW13 from '../../hw13/HW13'
|
// import HW13 from '../../hw13/HW13'
|
||||||
|
|
||||||
function JuniorPlus() {
|
function JuniorPlus() {
|
||||||
@@ -9,7 +9,7 @@ function JuniorPlus() {
|
|||||||
<div id={'hw5-page-junior-plus'}>
|
<div id={'hw5-page-junior-plus'}>
|
||||||
<HW10 />
|
<HW10 />
|
||||||
<HW11 />
|
<HW11 />
|
||||||
{/*<HW12 />*/}
|
<HW12 />
|
||||||
{/*<HW13 />*/}
|
{/*<HW13 />*/}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -33,8 +33,8 @@ function Clock() {
|
|||||||
setShow(false)
|
setShow(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
const stringTime = date.toLocaleTimeString() || <br/> // часы24:минуты:секунды (01:02:03)/(23:02:03)/(24:00:00)/(00:00:01) // пишут студенты
|
const stringTime = date.toLocaleTimeString('ru-Ru') || <br/> // часы24:минуты:секунды (01:02:03)/(23:02:03)/(24:00:00)/(00:00:01) // пишут студенты
|
||||||
const stringDate = date.toLocaleDateString() || <br/> // день.месяц.год (01.02.2022) // пишут студенты, варианты 01.02.0123/01.02.-123/01.02.12345 не рассматриваем
|
const stringDate = date.toLocaleDateString('ru-Ru') || <br/> // день.месяц.год (01.02.2022) // пишут студенты, варианты 01.02.0123/01.02.-123/01.02.12345 не рассматриваем
|
||||||
|
|
||||||
// день недели на английском, месяц на английском (https://learn.javascript.ru/intl#intl-datetimeformat)
|
// день недели на английском, месяц на английском (https://learn.javascript.ru/intl#intl-datetimeformat)
|
||||||
const stringDay = new Intl.DateTimeFormat('en-US', {weekday: 'long'}).format(date) || <br/> // пишут студенты
|
const stringDay = new Intl.DateTimeFormat('en-US', {weekday: 'long'}).format(date) || <br/> // пишут студенты
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import { loadingReducer } from './loadingReducer'
|
import { loadingReducer } from './loadingReducer'
|
||||||
import { combineReducers, legacy_createStore } from 'redux'
|
import { combineReducers, legacy_createStore } from 'redux'
|
||||||
// import { themeReducer } from '../../hw12/bll/themeReducer'
|
import { themeReducer } from '../../hw12/bll/themeReducer'
|
||||||
|
|
||||||
const reducers = combineReducers({
|
const reducers = combineReducers({
|
||||||
loading: loadingReducer, // hw10
|
loading: loadingReducer, // hw10
|
||||||
// theme: themeReducer, // hw12
|
theme: themeReducer, // hw12
|
||||||
})
|
})
|
||||||
|
|
||||||
const store = legacy_createStore(reducers)
|
const store = legacy_createStore(reducers)
|
||||||
|
|||||||
@@ -1,23 +1,23 @@
|
|||||||
.dark {
|
[data-theme='1'] {
|
||||||
background: dimgrey;
|
--color: #000000;
|
||||||
|
--background: #FFFFFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dark-text {
|
[data-theme='2'] {
|
||||||
color: aliceblue;
|
--color: #000000;
|
||||||
|
--background: #DDEEFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
.red {
|
[data-theme='3'] {
|
||||||
background: lightcoral;
|
--color: #FFFFFF;
|
||||||
|
--background: #212A34;
|
||||||
}
|
}
|
||||||
|
|
||||||
.red-text {
|
html {
|
||||||
color: aqua;
|
background-color: var(--background);
|
||||||
|
color: var(--color);
|
||||||
}
|
}
|
||||||
|
|
||||||
.some {
|
.select {
|
||||||
background: lightgreen;
|
|
||||||
}
|
|
||||||
|
|
||||||
.some-text {
|
|
||||||
color: darkslateblue;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,33 +1,47 @@
|
|||||||
import React from 'react'
|
import React, {useEffect} from 'react'
|
||||||
import s from './HW12.module.css'
|
import s from './HW12.module.css'
|
||||||
import s2 from '../../s1-main/App.module.css'
|
import s2 from '../../s1-main/App.module.css'
|
||||||
import SuperSelect from '../hw07/common/c5-SuperSelect/SuperSelect'
|
import SuperSelect from '../hw07/common/c5-SuperSelect/SuperSelect'
|
||||||
import { useDispatch, useSelector } from 'react-redux'
|
import {useDispatch, useSelector} from 'react-redux'
|
||||||
import { changeThemeId } from './bll/themeReducer'
|
import {changeThemeId} from './bll/themeReducer'
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 1 - в файле themeReducer.ts написать нужные типы вместо any, дописать редьюсер
|
||||||
|
* 2 - получить themeId из редакса
|
||||||
|
* 3 - дописать тип и логику функции change
|
||||||
|
* 4 - передать пропсы в SuperSelect
|
||||||
|
* */
|
||||||
|
|
||||||
const themes = [
|
const themes = [
|
||||||
{ id: 1, value: 'light' },
|
{id: 1, value: 'light'},
|
||||||
{ id: 2, value: 'blue' },
|
{id: 2, value: 'blue'},
|
||||||
{ id: 3, value: 'dark' },
|
{id: 3, value: 'dark'},
|
||||||
]
|
]
|
||||||
|
|
||||||
const HW12 = () => {
|
const HW12 = () => {
|
||||||
|
// взять ид темы из редакса
|
||||||
const themeId = useSelector((state: any) => state.theme.themeId)
|
const themeId = useSelector((state: any) => state.theme.themeId)
|
||||||
const theme = themes.find((t) => t.id === themeId)!.value
|
|
||||||
|
|
||||||
const dispatch = useDispatch()
|
const dispatch = useDispatch()
|
||||||
const change = (id: number) => {
|
|
||||||
|
const change = (id: any) => { // дописать функцию
|
||||||
dispatch(changeThemeId(id))
|
dispatch(changeThemeId(id))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
document.documentElement.dataset.theme = themeId + ''
|
||||||
|
}, [themeId])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div id={'hw12'}>
|
<div id={'hw12'}>
|
||||||
<div id={'hw12-text'} className={s2.hwTitle}>
|
<div id={'hw12-text'} className={s2.hwTitle}>
|
||||||
Homework #12
|
Homework #12
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className={s2.hw}>
|
<div className={s2.hw}>
|
||||||
<SuperSelect
|
<SuperSelect
|
||||||
id={'hw12-select-theme'}
|
id={'hw12-select-theme'}
|
||||||
|
className={s.select}
|
||||||
|
// сделать переключение тем
|
||||||
value={themeId}
|
value={themeId}
|
||||||
options={themes}
|
options={themes}
|
||||||
onChangeOption={change}
|
onChangeOption={change}
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ const initState = {
|
|||||||
themeId: 1,
|
themeId: 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
export const themeReducer = (state = initState, action: any): any => {
|
export const themeReducer = (state = initState, action: any): any => { // fix any
|
||||||
// fix any
|
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
|
// дописать
|
||||||
case 'SET_THEME_ID': {
|
case 'SET_THEME_ID': {
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
|
|||||||
Reference in New Issue
Block a user