-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into 783-clear2-0-order-ratio-bug
- Loading branch information
Showing
6 changed files
with
73 additions
and
67 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
10 changes: 0 additions & 10 deletions
10
packages/ui-components/src/__tests__/CodeMirrorRainlang.test.svelte
This file was deleted.
Oops, something went wrong.
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
34 changes: 29 additions & 5 deletions
34
packages/ui-components/src/lib/components/CodeMirrorRainlang.svelte
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 |
---|---|---|
@@ -1,14 +1,38 @@ | ||
<script lang="ts"> | ||
import type { Order } from '@rainlanguage/orderbook/js_api'; | ||
import { extendOrder } from '@rainlanguage/orderbook/js_api'; | ||
import CodeMirror from 'svelte-codemirror-editor'; | ||
import { RainlangLR } from 'codemirror-rainlang'; | ||
export let order: Order | undefined = undefined; | ||
export let rainlangText: string = ''; | ||
export let rainlangText: string | undefined = undefined; | ||
export let codeMirrorTheme; | ||
export let disabled = false; | ||
export let styles = {}; | ||
export let codeMirrorDisabled = true; | ||
export let codeMirrorStyles = {}; | ||
$: value = order ? extendOrder(order).rainlang : rainlangText; | ||
$: extendedOrder = order ? extendOrder(order) : undefined; | ||
</script> | ||
|
||
<slot name="codemirror" {value} {codeMirrorTheme} {disabled} {styles}></slot> | ||
{#if extendedOrder?.rainlang} | ||
<CodeMirror | ||
value={rainlangText || extendedOrder.rainlang} | ||
extensions={[RainlangLR]} | ||
theme={codeMirrorTheme} | ||
readonly={codeMirrorDisabled} | ||
useTab={true} | ||
tabSize={2} | ||
styles={{ | ||
'&': { | ||
width: '100%' | ||
}, | ||
...codeMirrorStyles | ||
}} | ||
/> | ||
{:else if !extendedOrder?.rainlang && !rainlangText} | ||
<div | ||
class="w-full tracking-tight text-gray-900 dark:text-white" | ||
data-testid="rainlang-not-included" | ||
> | ||
Rain source not included in order meta | ||
</div> | ||
{/if} |
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