|
|
@ -3,7 +3,9 @@ |
|
|
|
import React, { |
|
|
|
import React, { |
|
|
|
Fragment, |
|
|
|
Fragment, |
|
|
|
useEffect, |
|
|
|
useEffect, |
|
|
|
useRef |
|
|
|
useReducer, |
|
|
|
|
|
|
|
useRef, |
|
|
|
|
|
|
|
useState |
|
|
|
} from 'react' |
|
|
|
} from 'react' |
|
|
|
|
|
|
|
|
|
|
|
import './remix-ui-vertical-icons-panel.css' |
|
|
|
import './remix-ui-vertical-icons-panel.css' |
|
|
@ -12,17 +14,44 @@ import { VerticalIcons } from '../../types/vertical-icons-panel' |
|
|
|
import Home from './components/Home' |
|
|
|
import Home from './components/Home' |
|
|
|
import Settings from './components/Settings' |
|
|
|
import Settings from './components/Settings' |
|
|
|
import { RequiredSection } from './components/RequiredSection' |
|
|
|
import { RequiredSection } from './components/RequiredSection' |
|
|
|
|
|
|
|
import { verticalScrollReducer } from './reducers/verticalScrollReducer' |
|
|
|
export interface RemixUiVerticalIconsPanelProps { |
|
|
|
export interface RemixUiVerticalIconsPanelProps { |
|
|
|
verticalIconsPlugin: VerticalIcons |
|
|
|
verticalIconsPlugin: VerticalIcons |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let scrollHeight: any |
|
|
|
let scrollHeight: any |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const initialState = { |
|
|
|
|
|
|
|
scrollHeight: 0, |
|
|
|
|
|
|
|
clientHeight: 0, |
|
|
|
|
|
|
|
scrollState: false |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export function RemixUiVerticalIconsPanel ({ |
|
|
|
export function RemixUiVerticalIconsPanel ({ |
|
|
|
verticalIconsPlugin |
|
|
|
verticalIconsPlugin |
|
|
|
}: RemixUiVerticalIconsPanelProps) { |
|
|
|
}: RemixUiVerticalIconsPanelProps) { |
|
|
|
const scrollableRef = useRef<any>() |
|
|
|
const scrollableRef = useRef<any>() |
|
|
|
const iconPanelRef = useRef<any>() |
|
|
|
const iconPanelRef = useRef<any>() |
|
|
|
|
|
|
|
const [activateScroll, dispatchScrollAction] = useReducer(verticalScrollReducer, initialState) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
|
|
|
const evaluateScrollability = (evt: any) => { |
|
|
|
|
|
|
|
console.log('resize event answered by dispatch!') |
|
|
|
|
|
|
|
dispatchScrollAction({ |
|
|
|
|
|
|
|
type: 'resize', |
|
|
|
|
|
|
|
payload: { |
|
|
|
|
|
|
|
scrollHeight: document.querySelector('#remixuiScrollable')?.scrollHeight, |
|
|
|
|
|
|
|
clientHeight: document.querySelector('#remixuiScrollable')?.clientHeight, |
|
|
|
|
|
|
|
scrollState: false |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
addEventListener('resize', evaluateScrollability) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return () => { |
|
|
|
|
|
|
|
removeEventListener('resize', evaluateScrollability) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
function onThemeChanged (themeType: any) { |
|
|
|
function onThemeChanged (themeType: any) { |
|
|
|
const invert = themeType === 'dark' ? 1 : 0 |
|
|
|
const invert = themeType === 'dark' ? 1 : 0 |
|
|
@ -51,6 +80,7 @@ export function RemixUiVerticalIconsPanel ({ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function addActive (name: string) { |
|
|
|
function addActive (name: string) { |
|
|
|
|
|
|
|
console.log('addactive has been called now.') |
|
|
|
if (name === 'home') return |
|
|
|
if (name === 'home') return |
|
|
|
const themeType = verticalIconsPlugin.registry.get('themeModule').api.currentTheme().quality |
|
|
|
const themeType = verticalIconsPlugin.registry.get('themeModule').api.currentTheme().quality |
|
|
|
const invert = themeType === 'dark' ? 1 : 0 |
|
|
|
const invert = themeType === 'dark' ? 1 : 0 |
|
|
@ -98,7 +128,7 @@ export function RemixUiVerticalIconsPanel ({ |
|
|
|
<div className="remixui_icons d-flex flex-column vh-100" ref={iconPanelRef}> |
|
|
|
<div className="remixui_icons d-flex flex-column vh-100" ref={iconPanelRef}> |
|
|
|
<Home verticalIconPlugin={verticalIconsPlugin} /> |
|
|
|
<Home verticalIconPlugin={verticalIconsPlugin} /> |
|
|
|
<div className={scrollableRef.current && scrollableRef.current.scrollHeight > scrollableRef.current.clientHeight |
|
|
|
<div className={scrollableRef.current && scrollableRef.current.scrollHeight > scrollableRef.current.clientHeight |
|
|
|
? 'remixui_default-icons-container remixui_requiredSection' : 'remixui_requiredSection'}> |
|
|
|
? 'remixui_default-icons-container remixui_requiredSection' : activateScroll && activateScroll.scrollState ? 'remixui_default-icons-container remixui_requiredSection' : 'remixui_requiredSection'}> |
|
|
|
<RequiredSection |
|
|
|
<RequiredSection |
|
|
|
verticalIconsPlugin={verticalIconsPlugin} |
|
|
|
verticalIconsPlugin={verticalIconsPlugin} |
|
|
|
addActive={addActive} |
|
|
|
addActive={addActive} |
|
|
@ -111,7 +141,7 @@ export function RemixUiVerticalIconsPanel ({ |
|
|
|
id="remixuiScrollable" |
|
|
|
id="remixuiScrollable" |
|
|
|
className={scrollableRef.current && scrollableRef.current.scrollHeight > scrollableRef.current.clientHeight |
|
|
|
className={scrollableRef.current && scrollableRef.current.scrollHeight > scrollableRef.current.clientHeight |
|
|
|
? 'remixui_default-icons-container remixui_scrollable-container remixui_scrollbar remixui_hide-scroll' |
|
|
|
? 'remixui_default-icons-container remixui_scrollable-container remixui_scrollbar remixui_hide-scroll' |
|
|
|
: 'remixui_scrollable-container remixui_scrollbar remixui_hide-scroll'} |
|
|
|
: activateScroll && activateScroll.scrollState ? 'remixui_default-icons-container remixui_scrollable-container remixui_scrollbar remixui_hide-scroll' : 'remixui_scrollable-container remixui_scrollbar remixui_hide-scroll'} |
|
|
|
ref={scrollableRef} |
|
|
|
ref={scrollableRef} |
|
|
|
> |
|
|
|
> |
|
|
|
<OtherIcons |
|
|
|
<OtherIcons |
|
|
|