Skip to content

Commit

Permalink
website: update CodeMirror height style.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Jun 6, 2023
1 parent 159444d commit ec18778
Show file tree
Hide file tree
Showing 17 changed files with 39 additions and 37 deletions.
2 changes: 2 additions & 0 deletions www/src/components/Warpper.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import styled from 'styled-components';
import BackToUp from '@uiw/react-back-to-top';
import { useRef, useState, useEffect, FC, PropsWithChildren } from 'react';
import { ScrollRestoration } from 'react-router-dom';

const Container = styled.div`
width: 100%;
Expand All @@ -20,6 +21,7 @@ export const Warpper: FC<PropsWithChildren<{}>> = (props) => {
<BackToUp element={element} style={{ position: 'fixed' }}>
Top
</BackToUp>
<ScrollRestoration />
</Container>
);
};
5 changes: 0 additions & 5 deletions www/src/components/useMdData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ export const useMdData = (path: MdDataHandle) => {
});
const [loading, setLoading] = useState(false);

useEffect(() => {
const $main = document.getElementsByTagName('main') as HTMLCollectionOf<HTMLDivElement>;
$main[0] && $main[0].scrollTo(0, 0);
}, [path]);

useEffect(() => {
setLoading(() => true);
const getMd = async () => {
Expand Down
2 changes: 1 addition & 1 deletion www/src/pages/examples/Example431.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const PageExample431 = () => {
<CodeMirror
value={`console.log('hello')`}
theme="none"
height="400px"
height="400px !important"
width="100%"
style={{ margin: '0 0 23px 0', flex: 1 }}
extensions={[langs.markdown()]}
Expand Down
2 changes: 1 addition & 1 deletion www/src/pages/extensions/basic-setup/example.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const BasicSetupExample = (props: BasicSetupExampleProps) => {
value={props.source}
theme={theme}
basicSetup={basicSetup}
height="300px"
height="300px !important"
style={{ margin: '0 0 23px 0' }}
extensions={[langs.markdown()]}
/>
Expand Down
2 changes: 1 addition & 1 deletion www/src/pages/extensions/classname/example.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const ClassNameExample: FC<PropsWithChildren<{ source?: string }>> = ({ s
<CodeMirror
value={source}
theme={theme}
height="300px"
height="300px !important"
style={{ margin: '0 0 23px 0' }}
extensions={[
langs.markdown(),
Expand Down
2 changes: 1 addition & 1 deletion www/src/pages/extensions/color/example.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const ColorExample = () => {
<CodeMirror
value={codeSample}
theme={theme}
height="400px"
height="400px !important"
// editable={readOnly}
// readOnly={readOnly}
{...porps}
Expand Down
2 changes: 1 addition & 1 deletion www/src/pages/extensions/events/example.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const EventsExample: FC<PropsWithChildren<{ source?: string }>> = ({ sour
<CodeMirror
value={source}
theme={theme}
height="200px"
height="200px !important"
style={{ margin: '0 0 23px 0' }}
extensions={[
langs.markdown(),
Expand Down
2 changes: 1 addition & 1 deletion www/src/pages/extensions/hyper-link/example.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const HyperLinkExample = () => {
<CodeMirror
value={markdownString}
theme={theme}
height="300px"
height="300px !important"
style={{ margin: '0 0 23px 0' }}
extensions={[langs.markdown(), hyperLink]}
/>
Expand Down
2 changes: 1 addition & 1 deletion www/src/pages/extensions/langs/example.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const LangsExample: FC<PropsWithChildren<{ source?: string }>> = (props)
<CodeMirror
value={source}
theme={theme}
height="300px"
height="300px !important"
style={{ margin: '0 0 23px 0' }}
extensions={[loadLanguage(language)!].filter(Boolean)}
/>
Expand Down
2 changes: 1 addition & 1 deletion www/src/pages/extensions/line-numbers-relative/example.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const LineNumbersRelativeExample: FC<PropsWithChildren<{ source?: string
<CodeMirror
value={source}
theme={theme}
height="300px"
height="300px !important"
style={{ margin: '0 0 23px 0' }}
extensions={[langs.markdown(), lineNumbersRelative]}
/>
Expand Down
2 changes: 1 addition & 1 deletion www/src/pages/extensions/mentions/example.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export const MentionsExample: FC<PropsWithChildren<{ source?: string }>> = ({ so
<CodeMirror
value={source}
theme={theme}
height="300px"
height="300px !important"
style={{ margin: '0 0 23px 0' }}
extensions={[langs.markdown(), mentions(users)]}
/>
Expand Down
2 changes: 1 addition & 1 deletion www/src/pages/extensions/themes/example.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const ThemesAllExample: FC<PropsWithChildren<{ source?: string }>> = ({ s
<CodeMirror
value={source}
theme={themeCurrent as ReactCodeMirrorProps['theme']}
height="300px"
height="300px !important"
style={{ margin: '0 0 23px 0' }}
extensions={[langs.markdown()]}
/>
Expand Down
4 changes: 2 additions & 2 deletions www/src/pages/extensions/zebra-stripes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const ZebraStripesExample: FC<PropsWithChildren<{ source?: string }>> = (
<CodeMirror
value={source}
theme={theme}
height="300px"
height="300px !important"
style={{ margin: '0 0 23px 0' }}
extensions={[langs.markdown(), zebra]}
/>
Expand All @@ -39,7 +39,7 @@ export const ZebraStripesExample: FC<PropsWithChildren<{ source?: string }>> = (
<CodeMirror
value={source}
theme={theme}
height="300px"
height="300px !important"
style={{ margin: '0 0 23px 0' }}
extensions={[
langs.markdown(),
Expand Down
2 changes: 1 addition & 1 deletion www/src/pages/home/Example.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export default function Example() {
<Warpper className="wmde-markdown-var">
<CodemirrorWarpper
value={code}
height={height}
height={`${height} !important`}
theme={alls[theme as keyof typeof alls] || theme}
editable={editable}
extensions={extensions}
Expand Down
4 changes: 2 additions & 2 deletions www/src/pages/theme/editor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export function ThemeEditor() {
selectionMatch: '#D6D6D6',
gutterBackground: '#FFFFFF',
gutterForeground: '#4D4D4C',
gutterBorder: '#ddd',
gutterBorder: '#dddddd',
gutterActiveForeground: '',
lineHighlight: '#EFEFEF',
});
Expand Down Expand Up @@ -220,7 +220,7 @@ export function ThemeEditor() {
theme={myTheme}
extensions={[extension, color]}
value={lang === 'code' ? themeCode({ ...settings, ...styles, dark: theme }) : code}
height="100%"
height="100% !important"
style={{ minHeight: '100%' }}
/>
)}
Expand Down
2 changes: 1 addition & 1 deletion www/src/pages/theme/home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export function ThemesHome() {
<Title>{toTitleCase(name)}</Title>
<CodeEditor
value={codeString}
height="165px"
height="165px !important"
theme={themeData[name as keyof typeof themeData]}
extensions={[color, langs.jsx()]}
/>
Expand Down
37 changes: 21 additions & 16 deletions www/src/pages/theme/themes/Sample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,37 +39,42 @@ export const Sample: FC<PropsWithoutRef<SampleProps>> = ({ theme, ...props }) =>
return (
<Warpper {...props}>
<Title>JavaScript</Title>
<CodeMirror value={jsStr} height="300px" theme={theme} extensions={[color, langs.javascript()]} />
<CodeMirror value={jsStr} height="300px !important" theme={theme} extensions={[color, langs.javascript()]} />
<Title>JSX</Title>
<CodeMirror value={jsxStr} height="300px" theme={theme} extensions={[color, langs.jsx()]} />
<CodeMirror value={jsxStr} height="300px !important" theme={theme} extensions={[color, langs.jsx()]} />
<Title>TypeScript</Title>
<CodeMirror value={typescriptStr} height="300px" theme={theme} extensions={[color, langs.typescript()]} />
<CodeMirror
value={typescriptStr}
height="300px !important"
theme={theme}
extensions={[color, langs.typescript()]}
/>
<Title>TSX</Title>
<CodeMirror value={tsxStr} height="300px" theme={theme} extensions={[color, langs.tsx()]} />
<CodeMirror value={tsxStr} height="300px !important" theme={theme} extensions={[color, langs.tsx()]} />
<Title>JSON</Title>
<CodeMirror value={jsonStr} height="300px" theme={theme} extensions={[color, langs.json()]} />
<CodeMirror value={jsonStr} height="300px !important" theme={theme} extensions={[color, langs.json()]} />
<Title>HTML</Title>
<CodeMirror value={htmlStr} height="300px" theme={theme} extensions={[color, langs.html()]} />
<CodeMirror value={htmlStr} height="300px !important" theme={theme} extensions={[color, langs.html()]} />
<Title>Markdown</Title>
<CodeMirror value={markdownStr} height="300px" theme={theme} extensions={[color, langs.markdown()]} />
<CodeMirror value={markdownStr} height="300px !important" theme={theme} extensions={[color, langs.markdown()]} />
<Title>CSS</Title>
<CodeMirror value={cssStr} height="300px" theme={theme} extensions={[color, langs.css()]} />
<CodeMirror value={cssStr} height="300px !important" theme={theme} extensions={[color, langs.css()]} />
<Title>PHP</Title>
<CodeMirror value={phpStr} height="300px" theme={theme} extensions={[color, langs.php()]} />
<CodeMirror value={phpStr} height="300px !important" theme={theme} extensions={[color, langs.php()]} />
<Title>JAVA</Title>
<CodeMirror value={javaStr} height="300px" theme={theme} extensions={[color, langs.java()]} />
<CodeMirror value={javaStr} height="300px !important" theme={theme} extensions={[color, langs.java()]} />
<Title>Rust</Title>
<CodeMirror value={rustStr} height="300px" theme={theme} extensions={[color, langs.rust()]} />
<CodeMirror value={rustStr} height="300px !important" theme={theme} extensions={[color, langs.rust()]} />
<Title>Go</Title>
<CodeMirror value={goStr} height="300px" theme={theme} extensions={[color, langs.go()]} />
<CodeMirror value={goStr} height="300px !important" theme={theme} extensions={[color, langs.go()]} />
<Title>MySQL</Title>
<CodeMirror value={mysqlStr} height="300px" theme={theme} extensions={[color, langs.mysql()]} />
<CodeMirror value={mysqlStr} height="300px !important" theme={theme} extensions={[color, langs.mysql()]} />
<Title>Python</Title>
<CodeMirror value={pythonStr} height="300px" theme={theme} extensions={[color, langs.python()]} />
<CodeMirror value={pythonStr} height="300px !important" theme={theme} extensions={[color, langs.python()]} />
<Title>Shell</Title>
<CodeMirror value={shellStr} height="300px" theme={theme} extensions={[color, langs.shell()]} />
<CodeMirror value={shellStr} height="300px !important" theme={theme} extensions={[color, langs.shell()]} />
<Title>Swift</Title>
<CodeMirror value={swiftStr} height="300px" theme={theme} extensions={[color, langs.swift()]} />
<CodeMirror value={swiftStr} height="300px !important" theme={theme} extensions={[color, langs.swift()]} />
</Warpper>
);
};

0 comments on commit ec18778

Please sign in to comment.