Skip to content

Commit 5f60c12

Browse files
committed
website: fix placeholder issue.
1 parent 38d940a commit 5f60c12

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

website/pages/run/Textarea.module.less

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
-webkit-font-smoothing: antialiased;
2929
-webkit-text-fill-color: transparent;
3030
outline: 0;
31+
&:global(.empty) {
32+
-webkit-text-fill-color: #bfbfbf;
33+
}
3134
}
3235

3336
.codePreview {

website/pages/run/Textarea.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ interface TextareaProps extends React.TextareaHTMLAttributes<HTMLTextAreaElement
3535
}
3636

3737
const Textarea = (props: TextareaProps) => {
38-
const { language, value = '' } = props;
38+
const { className, language, value = '', ...other } = props;
3939
const textRef = useRef<HTMLTextAreaElement>(null);
4040
const viewRef = useRef<HTMLDivElement>(null);
4141
useEffect(() => {
@@ -52,9 +52,9 @@ const Textarea = (props: TextareaProps) => {
5252
autoCorrect="off"
5353
spellCheck="false"
5454
autoCapitalize="off"
55-
className={styles.textarea}
55+
{...other}
5656
ref={textRef}
57-
{...props}
57+
className={`${className || ''} ${styles.textarea}`}
5858
value={value}
5959
/>
6060
<div

website/pages/run/index.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ export default function Run() {
5151
<TextareaEditor
5252
value={htmlStr}
5353
language="html"
54+
className={htmlStr ? '' : 'empty'}
55+
placeholder="Please enter HTML code."
5456
onPaste={(event) => {
5557
let paste = (event.clipboardData || (window as any).clipboardData).getData('text');
5658
setHtmlStr(paste.replace(/^\n+/g, '').replace(/\n+$/g, ''));
@@ -70,6 +72,8 @@ export default function Run() {
7072
<TextareaEditor
7173
value={jsStr}
7274
language="js"
75+
className={jsStr ? '' : 'empty'}
76+
placeholder="Please enter JavaScript code."
7377
onPaste={(event) => {
7478
let paste = (event.clipboardData || (window as any).clipboardData).getData('text');
7579
setJsStr(paste.replace(/^\n+/g, '').replace(/\n+$/g, ''));
@@ -89,6 +93,8 @@ export default function Run() {
8993
<TextareaEditor
9094
value={cssStr}
9195
language="css"
96+
className={cssStr ? '' : 'empty'}
97+
placeholder="Please enter CSS code."
9298
onPasteCapture={(event) => {
9399
let paste = (event.clipboardData || (window as any).clipboardData).getData('text');
94100
paste = paste.replace(/^\n+/g, '').replace(/\n+$/g, '');

0 commit comments

Comments
 (0)