mirror of
https://github.com/billsonnn/nitro-react.git
synced 2025-01-18 21:36:27 +01:00
Update
This commit is contained in:
parent
58ccb340df
commit
87d16f355c
@ -10,7 +10,7 @@ export const NitropediaView: FC<{}> = props =>
|
|||||||
{
|
{
|
||||||
const [ content, setContent ] = useState<string>(null);
|
const [ content, setContent ] = useState<string>(null);
|
||||||
const [ header, setHeader] = useState<string>('');
|
const [ header, setHeader] = useState<string>('');
|
||||||
const [wH, setWH] = useState<{w:number,h:number}>({ w:0, h:0 });
|
const [ dimensions, setDimensions ] = useState<{ width: number, height: number}>(null);
|
||||||
const elementRef = useRef<HTMLDivElement>(null);
|
const elementRef = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
const openPage = useCallback(async (link: string) =>
|
const openPage = useCallback(async (link: string) =>
|
||||||
@ -22,19 +22,26 @@ export const NitropediaView: FC<{}> = props =>
|
|||||||
if(!response) return;
|
if(!response) return;
|
||||||
|
|
||||||
const text = await response.text();
|
const text = await response.text();
|
||||||
|
|
||||||
const splitData = text.split(NEW_LINE_REGEX);
|
const splitData = text.split(NEW_LINE_REGEX);
|
||||||
|
const line = splitData.shift().split('|');
|
||||||
|
|
||||||
setWH({ w: 0, h: 0 });
|
|
||||||
|
|
||||||
BatchUpdates(() =>
|
BatchUpdates(() =>
|
||||||
{
|
{
|
||||||
let line = splitData.shift().split('|');
|
|
||||||
setHeader(line[0]);
|
setHeader(line[0]);
|
||||||
|
|
||||||
if(line[1] && line[1].split(';').length === 2)
|
setDimensions(prevValue =>
|
||||||
setWH({ w: parseInt(line[1].split(';')[0]), h: parseInt(line[1].split(';')[1]) });
|
{
|
||||||
|
if(line[1] && (line[1].split(';').length === 2))
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
width: parseInt(line[1].split(';')[0]),
|
||||||
|
height: parseInt(line[1].split(';')[1])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
|
||||||
setContent(splitData.join(''));
|
setContent(splitData.join(''));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -91,8 +98,8 @@ export const NitropediaView: FC<{}> = props =>
|
|||||||
if(!content) return null;
|
if(!content) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<NitroCardView className="nitropedia" theme="primary-slim" style={wH.w && wH.h ? { width: wH.w, height: wH.h } : {} }>
|
<NitroCardView className="nitropedia" theme="primary-slim" style={ dimensions ? { width: dimensions.width, height: dimensions.height } : {} }>
|
||||||
<NitroCardHeaderView headerText={header} onCloseClick={() => setContent(null)}/>
|
<NitroCardHeaderView headerText={header} onCloseClick={ () => setContent(null) }/>
|
||||||
<NitroCardContentView>
|
<NitroCardContentView>
|
||||||
<Base fit innerRef={ elementRef } className="text-black" dangerouslySetInnerHTML={{ __html: content }} />
|
<Base fit innerRef={ elementRef } className="text-black" dangerouslySetInnerHTML={{ __html: content }} />
|
||||||
</NitroCardContentView>
|
</NitroCardContentView>
|
||||||
|
Loading…
Reference in New Issue
Block a user