forked from illacloud/illa-builder
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: 🐛 move bar z-index https://linear.app/illa/issue/BUG-631 * feat: 🚸 improve codesandbox * feat: ✨ movableModal * feat: ✨ codeEditor into movableModal * feat: ✨ update all action panel's title with modalCodeEditor
- Loading branch information
Showing
83 changed files
with
758 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
registry = https://registry.npmjs.org/ |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1900,7 +1900,6 @@ | |
} | ||
} | ||
}, | ||
"window": {}, | ||
"uuid": {}, | ||
"numbro": { | ||
"!type": "fn(number)", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
apps/builder/src/components/CodeEditor/ModalCodeMirror/content.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { cloneDeep } from "lodash" | ||
import { FC, useLayoutEffect, useRef, useState } from "react" | ||
import useMeasure from "react-use-measure" | ||
import { CodeEditor } from "@/components/CodeEditor" | ||
import { ModalBodyContent } from "@/components/CodeEditor/ModalCodeMirror/interface" | ||
import { | ||
applyCodeMirrorWrapperStyle, | ||
codeMirrorContainerStyle, | ||
contentWrapperStyle, | ||
descriptionStyle, | ||
} from "@/components/CodeEditor/ModalCodeMirror/style" | ||
|
||
export const ModalContent: FC<ModalBodyContent> = (props) => { | ||
const { description, lang, expectValueType, onChange, value, placeholder } = | ||
props | ||
|
||
const descriptionRef = useRef<HTMLParagraphElement | null>(null) | ||
const [canRender, setCanRender] = useState(false) | ||
const [descriptionHeight, setDescriptionHeight] = useState(0) | ||
|
||
useLayoutEffect(() => { | ||
if (descriptionRef.current) { | ||
const { height } = descriptionRef.current.getBoundingClientRect() | ||
setDescriptionHeight(height) | ||
} | ||
setCanRender(true) | ||
return () => { | ||
if (descriptionRef.current) { | ||
descriptionRef.current = null | ||
} | ||
} | ||
}, []) | ||
|
||
return ( | ||
<div css={contentWrapperStyle}> | ||
{description && ( | ||
<p css={descriptionStyle} ref={descriptionRef}> | ||
{description} | ||
</p> | ||
)} | ||
{canRender && ( | ||
<div css={applyCodeMirrorWrapperStyle(descriptionHeight)}> | ||
<CodeEditor | ||
placeholder={placeholder} | ||
showLineNumbers | ||
height="100%" | ||
minHeight="88px" | ||
maxHeight="100%" | ||
value={value} | ||
lang={lang} | ||
canShowCompleteInfo | ||
expectValueType={expectValueType} | ||
wrapperCss={codeMirrorContainerStyle} | ||
onChange={onChange} | ||
canExpand={false} | ||
/> | ||
</div> | ||
)} | ||
</div> | ||
) | ||
} |
19 changes: 19 additions & 0 deletions
19
apps/builder/src/components/CodeEditor/ModalCodeMirror/footer.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { FC } from "react" | ||
import { useTranslation } from "react-i18next" | ||
import { Button } from "@illa-design/react" | ||
import { FooterContentProps } from "@/components/CodeEditor/ModalCodeMirror/interface" | ||
import { saveButtonStyle } from "@/components/CodeEditor/ModalCodeMirror/style" | ||
|
||
export const FooterContent: FC<FooterContentProps> = (props) => { | ||
const { t } = useTranslation() | ||
const { onClickSaveButton } = props | ||
return ( | ||
<Button | ||
colorScheme="techPurple" | ||
onClick={onClickSaveButton} | ||
_css={saveButtonStyle} | ||
> | ||
{t("save")} | ||
</Button> | ||
) | ||
} |
46 changes: 46 additions & 0 deletions
46
apps/builder/src/components/CodeEditor/ModalCodeMirror/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { FC } from "react" | ||
import { useTranslation } from "react-i18next" | ||
import { ModalContent } from "@/components/CodeEditor/ModalCodeMirror/content" | ||
import { FooterContent } from "@/components/CodeEditor/ModalCodeMirror/footer" | ||
import { ModalCodeMirrorProps } from "@/components/CodeEditor/ModalCodeMirror/interface" | ||
import { MovableModal } from "@/components/MovableModal" | ||
|
||
export const ModalCodeMirror: FC<ModalCodeMirrorProps> = (props) => { | ||
const { | ||
title, | ||
value, | ||
description, | ||
lang, | ||
expectValueType, | ||
onChange, | ||
onClickSaveButton, | ||
onClose, | ||
placeholder, | ||
} = props | ||
const { t } = useTranslation() | ||
|
||
return ( | ||
<MovableModal | ||
title={title || t("editor.inspect.setter_label.code.write_code")} | ||
bodyContent={ | ||
<ModalContent | ||
description={ | ||
description || | ||
t("editor.inspect.setter_description.code.write_code") | ||
} | ||
lang={lang} | ||
expectValueType={expectValueType} | ||
value={value} | ||
onChange={onChange} | ||
placeholder={placeholder} | ||
/> | ||
} | ||
footerContent={ | ||
onClickSaveButton ? ( | ||
<FooterContent onClickSaveButton={onClickSaveButton} /> | ||
) : null | ||
} | ||
onClose={onClose} | ||
/> | ||
) | ||
} |
21 changes: 21 additions & 0 deletions
21
apps/builder/src/components/CodeEditor/ModalCodeMirror/interface.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { CodeEditorProps } from "@/components/CodeEditor/interface" | ||
import { MovableModalProps } from "@/components/MovableModal/interface" | ||
|
||
export interface ModalBodyContent { | ||
description?: string | ||
placeholder?: string | ||
lang?: CodeEditorProps["lang"] | ||
expectValueType?: CodeEditorProps["expectValueType"] | ||
onChange?: CodeEditorProps["onChange"] | ||
value: string | ||
} | ||
|
||
export interface FooterContentProps { | ||
onClickSaveButton: () => void | ||
} | ||
|
||
export interface ModalCodeMirrorProps | ||
extends Omit<MovableModalProps, "bodyContent" | "footerContent">, | ||
ModalBodyContent { | ||
onClickSaveButton?: () => void | ||
} |
32 changes: 32 additions & 0 deletions
32
apps/builder/src/components/CodeEditor/ModalCodeMirror/style.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { css } from "@emotion/react" | ||
import { getColor } from "@illa-design/react" | ||
|
||
export const descriptionStyle = css` | ||
font-size: 14px; | ||
color: ${getColor("grayBlue", "04")}; | ||
font-weight: 400; | ||
line-height: 22px; | ||
margin: 0; | ||
` | ||
|
||
export const applyCodeMirrorWrapperStyle = (desHeight: number) => css` | ||
width: 100%; | ||
height: max(88px, calc(100% - ${desHeight}px - 16px)); | ||
` | ||
|
||
export const codeMirrorContainerStyle = css` | ||
height: 100%; | ||
` | ||
|
||
export const saveButtonStyle = css` | ||
position: absolute; | ||
right: 16px; | ||
` | ||
|
||
export const contentWrapperStyle = css` | ||
width: 100%; | ||
height: 100%; | ||
display: flex; | ||
flex-direction: column; | ||
gap: 16px; | ||
` |
Oops, something went wrong.