@@ -42,10 +42,7 @@ export interface IPreviewerProps extends IPreviewerComponentProps {
42
42
* @param file file path
43
43
* @param source file source object
44
44
*/
45
- function getSourceType (
46
- file : string ,
47
- source : IPreviewerComponentProps [ 'sources' ] [ '_' ]
48
- ) {
45
+ function getSourceType ( file : string , source : IPreviewerComponentProps [ 'sources' ] [ '_' ] ) {
49
46
// use file extension as source type first
50
47
let type = file . match ( / \. ( \w + ) $ / ) ?. [ 1 ]
51
48
@@ -62,14 +59,9 @@ const Previewer: React.FC<IPreviewerProps> = oProps => {
62
59
const props = useLocaleProps < IPreviewerProps > ( locale , oProps )
63
60
const isActive = history ?. location . hash === `#${ props . identifier } `
64
61
const isSingleFile = Object . keys ( props . sources ) . length === 1
65
- const openCSB = useCodeSandbox (
66
- props . hideActions ?. includes ( 'CSB' ) ? null : props
67
- )
62
+ const openCSB = useCodeSandbox ( props . hideActions ?. includes ( 'CSB' ) ? null : props )
68
63
69
- const [ execMotions , isMotionRunning ] = useMotions (
70
- props . motions || [ ] ,
71
- demoRef . current
72
- )
64
+ const [ execMotions , isMotionRunning ] = useMotions ( props . motions || [ ] , demoRef . current )
73
65
const [ copyCode , copyStatus ] = useCopy ( )
74
66
const [ currentFile , setCurrentFile ] = useState ( '_' )
75
67
const [ sourceType , setSourceType ] = useState (
@@ -99,12 +91,8 @@ const Previewer: React.FC<IPreviewerProps> = oProps => {
99
91
data-debug = { props . debug || undefined }
100
92
>
101
93
< div className = '__dumi-default-previewer-desc' data-title = { props . title } >
102
- { props . title && (
103
- < AnchorLink to = { `#${ props . identifier } ` } > { props . title } </ AnchorLink >
104
- ) }
105
- { props . description && (
106
- < div dangerouslySetInnerHTML = { { __html : props . description } } />
107
- ) }
94
+ { props . title && < AnchorLink to = { `#${ props . identifier } ` } > { props . title } </ AnchorLink > }
95
+ { props . description && < div dangerouslySetInnerHTML = { { __html : props . description } } /> }
108
96
</ div >
109
97
< div className = '__dumi-default-previewer-actions' >
110
98
{ props . debug && < span className = 'debug-badge' > Debug Only</ span > }
@@ -156,10 +144,7 @@ const Previewer: React.FC<IPreviewerProps> = oProps => {
156
144
< Tabs . Tab
157
145
title = {
158
146
filename === '_'
159
- ? `index.${ getSourceType (
160
- filename ,
161
- props . sources [ filename ]
162
- ) } `
147
+ ? `index.${ getSourceType ( filename , props . sources [ filename ] ) } `
163
148
: filename
164
149
}
165
150
key = { filename }
@@ -168,11 +153,7 @@ const Previewer: React.FC<IPreviewerProps> = oProps => {
168
153
</ Tabs >
169
154
) }
170
155
< div className = '__dumi-default-previewer-source' >
171
- < SourceCode
172
- code = { currentFileCode }
173
- lang = { sourceType }
174
- showCopy = { false }
175
- />
156
+ < SourceCode code = { currentFileCode } lang = { sourceType } showCopy = { false } />
176
157
</ div >
177
158
</ div >
178
159
</ div >
0 commit comments