|
|
@ -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,48 @@ 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) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
|
|
|
addEventListener('activate', () => console.log('activate called now')) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
function onThemeChanged (themeType: any) { |
|
|
|
function onThemeChanged (themeType: any) { |
|
|
|
const invert = themeType === 'dark' ? 1 : 0 |
|
|
|
const invert = themeType === 'dark' ? 1 : 0 |
|
|
@ -51,6 +84,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 |
|
|
|