Remove Styled-components code

main
NB 4 years ago
parent 2075d04b6e
commit 812e4bf382
  1. 14
      src/modules/epubViewer/EpubViewer.tsx
  2. 15
      src/modules/epubViewer/style.ts
  3. 12
      src/modules/epubViewer/styles.ts
  4. 8
      src/modules/reactViewer/ReactViewer.tsx
  5. 2
      src/types/index.d.ts

@ -1,7 +1,13 @@
import React, { useState, useEffect, useCallback, useRef } from 'react' import React, {
useState,
useEffect,
useCallback,
useRef,
CSSProperties
} from 'react'
import { Book, Rendition } from "epubjs"; import { Book, Rendition } from "epubjs";
// style // style
import EpubViewerWrapper from 'modules/epubViewer/style' import styles from 'modules/epubViewer/styles'
// types // types
import { EpubViewerProps, ViewerRef } from 'types' import { EpubViewerProps, ViewerRef } from 'types'
import Toc from 'types/toc' import Toc from 'types/toc'
@ -39,6 +45,8 @@ const EpubViewer = ({
loadingView, loadingView,
}: EpubViewerProps, ref: React.RefObject<ViewerRef> | any) => { }: EpubViewerProps, ref: React.RefObject<ViewerRef> | any) => {
// TODO Fix the ref type correctly instead 'any' type. // TODO Fix the ref type correctly instead 'any' type.
const viewerStyle: CSSProperties = style ? { ...styles, ...style} : styles;
const [isLoaded, setIsLoaded] = useState(false); const [isLoaded, setIsLoaded] = useState(false);
const [book, setBook] = useState<Book | null>(null); const [book, setBook] = useState<Book | null>(null);
@ -286,7 +294,7 @@ const EpubViewer = ({
return (<> return (<>
{!isLoaded && loadingView} {!isLoaded && loadingView}
<EpubViewerWrapper ref={ref} style={style} /> <div ref={ref} style={viewerStyle} />
</>); </>);
} }

@ -1,15 +0,0 @@
import styled from 'styled-components'
const EpubViewerWrapper = styled.div`
width: 100%;
box-sizing: border-box;
margin: 0 auto;
& > div {
&::-webkit-scrollbar {
display: none;
}
}
`;
export default EpubViewerWrapper

@ -0,0 +1,12 @@
/**
* EpubViewer wrapper style
*/
const styles: {
boxSizing: any,
margin: any
} = {
boxSizing: "border-box",
margin: "0px auto"
}
export default styles

@ -1,4 +1,10 @@
import React, { useState, useEffect, useRef, useCallback, useMemo } from "react" import React, {
useState,
useEffect,
useRef,
useCallback,
useMemo
} from "react"
import { Book, Rendition, Contents } from "epubjs" import { Book, Rendition, Contents } from "epubjs"
// modules // modules
import EpubViewer from "modules/epubViewer/EpubViewer" import EpubViewer from "modules/epubViewer/EpubViewer"

@ -60,7 +60,7 @@ export interface EpubViewerProps {
url: string; url: string;
epubFileOptions?: BookOptions; epubFileOptions?: BookOptions;
epubOptions?: RenditionOptions; epubOptions?: RenditionOptions;
style?: Object; style?: React.CSSProperties;
location?: string; location?: string;
bookChanged?(book: Book): void; bookChanged?(book: Book): void;
rendtionChanged?(rendition: Rendition): void; rendtionChanged?(rendition: Rendition): void;

Loading…
Cancel
Save