Skip to content

Commit

Permalink
refactor: cleanup Box (#7240)
Browse files Browse the repository at this point in the history
* refactor: cleanup box

* fix: bring back classes and fix props

* feat: bring back props

* fix: cleanup and remove backsticks

* fix amount filter css
  • Loading branch information
evavirseda authored Aug 29, 2023
1 parent fb2d811 commit 2ef97ea
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 34 deletions.
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 = ''
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

0 comments on commit 2ef97ea

Please sign in to comment.