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

refactor: cleanup Box #7240

Merged
merged 7 commits into from
Aug 29, 2023
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 packages/desktop/components/filter/FilterItem.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@

<style lang="scss">
filter-item {
:global(box) {
:global(box-content) {
@apply p-2;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
<KeyValueBox
keyText={localize('general.metadata')}
valueText={JSON.stringify(irc27Metadata, null, '\t')}
classes="whitespace-pre-wrap"
isPreText
/>
{/if}
</activity-details>
Expand Down
14 changes: 7 additions & 7 deletions packages/shared/components/boxes/AddressBox.svelte
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<script lang="ts">
import { Text, CopyableBox, FontWeight } from 'shared/components'
import { Text, CopyableBox, FontWeight, TextType } from 'shared/components'

export let address = ''
export let isCopyable = false
export let fontSize = 'base'
export let address: string = ''
export let isCopyable: boolean = false
export let fontSize: string = 'base'

let copyableBoxElement: CopyableBox

Expand All @@ -15,14 +15,14 @@
{#if address}
<CopyableBox bind:this={copyableBoxElement} col {isCopyable} value={address} clearBoxPadding {...$$restProps}>
{#if address.length > 20}
<Text type="pre" {fontSize} fontWeight={FontWeight.medium}>
<Text type={TextType.pre} {fontSize} fontWeight={FontWeight.medium}>
{address.slice(0, address.length / 2)}
</Text>
<Text type="pre" {fontSize} fontWeight={FontWeight.medium}>
<Text type={TextType.pre} {fontSize} fontWeight={FontWeight.medium}>
{address.slice(address.length / 2)}
</Text>
{:else}
<Text type="pre" {fontSize} fontWeight={FontWeight.medium}>
<Text type={TextType.pre} {fontSize} fontWeight={FontWeight.medium}>
{address}
</Text>
{/if}
Expand Down
33 changes: 15 additions & 18 deletions packages/shared/components/boxes/Box.svelte
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
<script lang="ts">
export let col = false
export let row = false
export let clearBackground = false
export let clearPadding = false
export let backgroundColor = 'gray-50'
export let darkBackgroundColor = 'gray-850'
export let classes = ''
export let col: boolean = false
export let row: boolean = false
export let clearBackground: boolean = false
export let clearPadding: boolean = false
export let backgroundColor: string = 'gray-50'
export let darkBackgroundColor: string = 'gray-850'
export let classes: string = ''
</script>

<box
class={`
w-full flex rounded-lg
${col ? 'flex-col' : ''}
${row ? 'flex-row' : ''}
${clearPadding ? '' : 'px-4 py-4'}
${backgroundColor && !clearBackground ? 'bg-' + backgroundColor : ''}
${darkBackgroundColor && !clearBackground ? 'dark:bg-' + darkBackgroundColor : ''}
${classes}
`}
<box-content
class="w-full flex rounded-lg
{clearPadding ? '' : 'px-4 py-4'}
{backgroundColor && !clearBackground ? 'bg-' + backgroundColor : ''}
{darkBackgroundColor && !clearBackground ? 'dark:bg-' + darkBackgroundColor : ''} {classes}"
class:flex-col={col}
class:flex-row={row}
>
<slot />
</box>
</box-content>
12 changes: 6 additions & 6 deletions packages/shared/components/boxes/CopyableBox.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
import { localize } from '@core/i18n'
import { onDestroy } from 'svelte'

export let value = ''
export let isCopyable = true
export let clearPadding = false
export let clearBoxPadding = false
export let offset: number = undefined
export let classes = ''
cpl121 marked this conversation as resolved.
Show resolved Hide resolved
export let value: string = ''
export let isCopyable: boolean = true
export let clearPadding: boolean = false
export let clearBoxPadding: boolean = false
export let offset: number | undefined = undefined
export let classes: string = ''

let tooltipAnchor: HTMLElement
let showTooltip = false
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/components/boxes/KeyValueBox.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
export let tooltipText: string = ''
export let shrink: boolean = false
export let isPreText: boolean = false
export let maxHeight: number = undefined
export let maxHeight: number | undefined = undefined
export let isLoading: boolean = false
export let outline: boolean = false

Expand Down