Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove sticky line in playground #452

Merged
merged 1 commit into from
Dec 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/scripts/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
],
"scripts": {
"test": "jest --clearCache && jest --verbose",
"lint": "eslint \"src/**/*.ts\" \"tests/**/*.ts\"",
"lint": "eslint \"src/**/*.ts\" \"playground/src/**/*.tsx\" \"tests/**/*.ts\"",
"clean": "./scripts/clean.sh",
"copy": "./scripts/copy.sh",
"modify-dts": "replace-in-file --configFile=config.replace.json",
Expand Down
8 changes: 4 additions & 4 deletions playground/src/components/App/App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { JSX } from 'react';
import { AppProvider } from '@components/AppProvider';
import { Burger } from '@components/Burger';
import { Header } from '@components/Header';
Expand All @@ -11,13 +11,13 @@ export const App = (): JSX.Element => {

return (
<AppProvider>
<div className={styles.wrapper}>
<div className={styles.wrapper}>
<Header />
<Playground />
<Footer />
<Footer />
</div>
<Options />
<Burger />
</AppProvider>
</AppProvider>
);
};
17 changes: 12 additions & 5 deletions playground/src/components/AppProvider/AppProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import React, { PropsWithChildren, createContext, useContext, useState, useEffect } from 'react';
import React, {
JSX,
ReactNode,
createContext,
useContext,
useState,
useEffect
} from 'react';
import { Mode, Source } from 'postcss-rtlcss/options';
import { PluginOptions, FetchOptions } from '@types';
import { breakpointSizes } from '@constants';
Expand Down Expand Up @@ -64,7 +71,7 @@ const windowSizes = getWindowSizes();

export const AppContext = createContext<AppProviderContext>({} as AppProviderContext);

export const AppProvider = (props: PropsWithChildren<{}>): JSX.Element => {
export const AppProvider = (props: { children?: ReactNode }): JSX.Element => {

let delay: number;
const [ code, setCode ] = useState<string>(null);
Expand All @@ -83,9 +90,9 @@ export const AppProvider = (props: PropsWithChildren<{}>): JSX.Element => {

const resize = (): void => {
if (delay) window.clearTimeout(delay);
delay = window.setTimeout((): void => {
delay = window.setTimeout((): void => {
const windowSizes = getWindowSizes();
setSizes(windowSizes);
setSizes(windowSizes);
}, 100);
};

Expand Down Expand Up @@ -123,7 +130,7 @@ export const AppProvider = (props: PropsWithChildren<{}>): JSX.Element => {
changeOptionsProcessEnv,
changeOptionsUseCalc,
changeOptionsGreedy,
windowSizes: sizes
windowSizes: sizes
};

return (
Expand Down
2 changes: 1 addition & 1 deletion playground/src/components/Burger/Burger.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { JSX } from 'react';
import { useAppContext } from '@components/AppProvider';
import * as styles from './Burger.module.scss';

Expand Down
9 changes: 8 additions & 1 deletion playground/src/components/CSSPanel/CSSPanel.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import React, {useEffect, useRef} from 'react';
import React, {
useEffect,
useRef,
JSX
} from 'react';
import { editor, languages } from 'monaco-editor';
import * as styles from './CSSPanel.module.scss';

Expand Down Expand Up @@ -36,6 +40,9 @@ export const CSSPanel = (props: CSSPanelProps): JSX.Element => {
theme: 'vs-dark',
contextmenu: !isMobile,
selectionHighlight: !isMobile,
stickyScroll: {
enabled: false
},
hover: {
enabled: false
},
Expand Down
2 changes: 1 addition & 1 deletion playground/src/components/Footer/Footer.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { JSX } from 'react';
import GitHubButton from 'react-github-btn';
import classnames from 'classnames';
import { Link } from '@components/Link';
Expand Down
2 changes: 1 addition & 1 deletion playground/src/components/Header/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useCallback } from 'react';
import React, { useCallback, JSX } from 'react';
import { Share } from '@icons/Share';
import { useAppContext } from '@components/AppProvider';
import { cssLines } from '@components/Playground/css';
Expand Down
2 changes: 1 addition & 1 deletion playground/src/components/Link/Link.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { PropsWithChildren } from 'react';
import React, { PropsWithChildren, JSX } from 'react';
import * as styles from './Link.module.scss';

export interface LinkProps {
Expand Down
6 changes: 3 additions & 3 deletions playground/src/components/Options/Options.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect } from 'react';
import React, { useEffect, JSX } from 'react';
import { Mode, Source } from 'postcss-rtlcss/options';
import { useAppContext } from '@components/AppProvider';
import { Switch } from '@components/Switch';
Expand Down Expand Up @@ -96,7 +96,7 @@ export const Options = (): JSX.Element => {
? fetchOptions.ignorePrefixedRules
: true
)
}}
}}
/>
</div>
{ /* processUrls */ }
Expand All @@ -122,7 +122,7 @@ export const Options = (): JSX.Element => {
{ /* processKeyFrames */ }
<div className={styles.panel}>
<Switch
labels={['processKeyFrames: false', 'processKeyFrames: true']}
labels={['processKeyFrames: false', 'processKeyFrames: true']}
onChange={changeProcessKeyframes}
attributes={{
checked: !!fetchOptions?.processKeyFrames
Expand Down
12 changes: 8 additions & 4 deletions playground/src/components/Playground/Playground.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import React, { useState, useEffect } from 'react';
import React, {
useState,
useEffect,
JSX
} from 'react';
import postcss, { LazyResult, Result } from 'postcss';
import postcssRTLCSS from 'postcss-rtlcss';
import { PluginOptions } from '@types';
Expand All @@ -8,7 +12,7 @@ import { cssLines } from './css';
import * as styles from './Playground.module.scss';

const flipLines = (lines: string, options: PluginOptions = {}): LazyResult => {
return postcss([postcssRTLCSS(options)]).process(lines);
return postcss([postcssRTLCSS(options)]).process(lines);
};

export const Playground = (): JSX.Element => {
Expand All @@ -21,14 +25,14 @@ export const Playground = (): JSX.Element => {
useEffect((): void => {
flipLines(lines, options).then((result: Result): void => {
setLinesFlipped(result.css);
}).catch((error): void => {
}).catch((error): void => {
setLinesFlipped(`/* ${error.name}: ${error.message} */`);
});
setCode(lines);
}, [ lines, options ]);

const onChangeCode = (code: string): void => {
setLines(code);
setLines(code);
};

const comonProps = {
Expand Down
7 changes: 6 additions & 1 deletion playground/src/components/Switch/Switch.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import React, { useState, useEffect, ChangeEvent } from 'react';
import React, {
JSX,
useState,
useEffect,
ChangeEvent
} from 'react';
import * as styles from './Switch.module.scss';

interface Attributes {
Expand Down
13 changes: 10 additions & 3 deletions playground/src/components/SwitchGroup/SwitchGroup.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import React, { useState, useEffect, ChangeEvent } from 'react';
import React, {
JSX,
useState,
useEffect,
ChangeEvent
} from 'react';
import classnames from 'classnames';
import * as styles from './SwitchGroup.module.scss';

Expand Down Expand Up @@ -38,7 +43,9 @@ export const SwitchGroup = (props: SwitchGroupProps): JSX.Element => {
const currentTarget = event.currentTarget;
const value = currentTarget.value;
setSelected(value);
onChange && onChange(value);
if (onChange) {
onChange(value);
}
};
return (
<div className={styles.component}>
Expand Down Expand Up @@ -68,7 +75,7 @@ export const SwitchGroup = (props: SwitchGroupProps): JSX.Element => {
);
})
}
</div>
</div>
</div>
);
};
11 changes: 8 additions & 3 deletions playground/src/hooks/useApi.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { useState, useEffect, useCallback, useMemo } from 'react';
import {
useState,
useEffect,
useCallback,
useMemo
} from 'react';
import { FetchOptions } from '@types';

interface UseApiProps {
Expand Down Expand Up @@ -122,7 +127,7 @@ export const useApi = (): UseApiProps => {
history.replaceState('', '', `#${id}`);
if (navigator.clipboard) {
navigator.clipboard.writeText(window.location.href);
}
}
})
.catch(() => {
setToken(null);
Expand All @@ -147,7 +152,7 @@ export const useApi = (): UseApiProps => {
setToken(newToken);
})
.catch(() => setReady(true));
}
}
}, [token]);

useEffect(() => {
Expand Down
39 changes: 21 additions & 18 deletions playground/src/icons/Share.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
import React from 'react';
import React, { JSX } from 'react';

interface ShareProps {
color?: string;
size?: number;
}

export const Share = (props: ShareProps): JSX.Element => {
const { color = '#FFF', size = 30 } = props;
return (
<svg
version="1.1"
xmlns="http://www.w3.org/2000/svg"
x="0px"
y="0px"
viewBox="0 0 30 30"
height={size}
width={size}
>
<path fill={color} d="M24.6,0c-3,0-5.4,2.4-5.4,5.4c0,0.1,0,0.3,0,0.4l-10,4.7C8.2,9.6,6.9,9,5.4,9C2.4,9,0,11.4,0,14.4c0,3,2.4,5.4,5.4,5.4
c0.9,0,1.8-0.2,2.6-0.7l4.3,3.7c-0.2,0.6-0.3,1.1-0.3,1.8c0,3,2.4,5.4,5.4,5.4c3,0,5.4-2.4,5.4-5.4s-2.4-5.4-5.4-5.4
c-0.9,0-1.8,0.2-2.6,0.7l-4.3-3.7c0.2-0.6,0.3-1.1,0.3-1.8c0-0.1,0-0.2,0-0.4l10-4.7c1,0.9,2.3,1.5,3.7,1.5c3,0,5.4-2.4,5.4-5.4
S27.6,0,24.6,0z"/>
</svg>
);
const { color = '#FFF', size = 30 } = props;
return (
<svg
version="1.1"
xmlns="http://www.w3.org/2000/svg"
x="0px"
y="0px"
viewBox="0 0 30 30"
height={size}
width={size}
>
<path
fill={color}
d="M24.6,0c-3,0-5.4,2.4-5.4,5.4c0,0.1,0,0.3,0,0.4l-10,4.7C8.2,9.6,6.9,9,5.4,9C2.4,9,0,11.4,0,14.4c0,3,2.4,5.4,5.4,5.4
c0.9,0,1.8-0.2,2.6-0.7l4.3,3.7c-0.2,0.6-0.3,1.1-0.3,1.8c0,3,2.4,5.4,5.4,5.4c3,0,5.4-2.4,5.4-5.4s-2.4-5.4-5.4-5.4
c-0.9,0-1.8,0.2-2.6,0.7l-4.3-3.7c0.2-0.6,0.3-1.1,0.3-1.8c0-0.1,0-0.2,0-0.4l10-4.7c1,0.9,2.3,1.5,3.7,1.5c3,0,5.4-2.4,5.4-5.4
S27.6,0,24.6,0z"
/>
</svg>
);
};
Loading