Skip to content
This repository has been archived by the owner on Jan 24, 2025. It is now read-only.

Commit

Permalink
chore: prettier fix
Browse files Browse the repository at this point in the history
  • Loading branch information
pedronauck committed Feb 27, 2019
1 parent a3cc319 commit da9fb4b
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 23 deletions.
28 changes: 17 additions & 11 deletions core/docz-theme-default/src/components/ui/Editor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,23 @@ export const Editor: React.SFC<EditorProps> = ({
if (editor) removeLastLine(editor)
}

const removeLastLine = useCallback((editor: any) => {
if (editor && !props.withLastLine && props.readOnly) {
const lastLine = editor.lastLine()
editor.doc.replaceRange('', { line: lastLine - 1 }, { line: lastLine })
}
}, [props.withLastLine, props.readOnly])

const handleChange = useCallback((editor: any, data: any, code: string) => {
onChange && onChange(code)
setCode(code)
}, [code])
const removeLastLine = useCallback(
(editor: any) => {
if (editor && !props.withLastLine && props.readOnly) {
const lastLine = editor.lastLine()
editor.doc.replaceRange('', { line: lastLine - 1 }, { line: lastLine })
}
},
[props.withLastLine, props.readOnly]
)

const handleChange = useCallback(
(editor: any, data: any, code: string) => {
onChange && onChange(code)
setCode(code)
},
[code]
)

const editorProps = (config: UseConfigObj) => ({
value: code,
Expand Down
24 changes: 15 additions & 9 deletions core/docz-theme-default/src/components/ui/Playground/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -202,15 +202,21 @@ const Playground: SFC<PlaygroundProps> = ({
setKey(key + 1)
}, [])

const transformCode = useCallback((code: string) => {
if (code.startsWith('()') || code.startsWith('class')) return code
return `<React.Fragment>${code}</React.Fragment>`
}, [code])

const codesandboxUrl = useCallback((native: boolean): string => {
const url = 'https://codesandbox.io/api/v1/sandboxes/define'
return `${url}?parameters=${codesandbox}${native ? `&editorsize=75` : ``}`
}, [codesandbox, native])
const transformCode = useCallback(
(code: string) => {
if (code.startsWith('()') || code.startsWith('class')) return code
return `<React.Fragment>${code}</React.Fragment>`
},
[code]
)

const codesandboxUrl = useCallback(
(native: boolean): string => {
const url = 'https://codesandbox.io/api/v1/sandboxes/define'
return `${url}?parameters=${codesandbox}${native ? `&editorsize=75` : ``}`
},
[codesandbox, native]
)

const unloadListener = useCallback(() => {
storage.delete()
Expand Down
9 changes: 6 additions & 3 deletions core/docz/src/components/Link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ import { Link as BaseLink, LinkProps, LinkGetProps } from '@reach/router'

export { LinkProps }
export const Link = React.forwardRef<any, LinkProps<any>>((props, ref) => {
const isActive = useCallback(({ isCurrent }: LinkGetProps) => {
return isCurrent ? { className: `${props.className} active` } : {}
}, [props.className])
const isActive = useCallback(
({ isCurrent }: LinkGetProps) => {
return isCurrent ? { className: `${props.className} active` } : {}
},
[props.className]
)

return <BaseLink {...props} getProps={isActive} ref={ref} />
})
Expand Down

0 comments on commit da9fb4b

Please sign in to comment.