Skip to content

Commit

Permalink
refactor: ProposalStatusInfo+InformationTooltip (#1949)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeeanribeiro authored Feb 15, 2024
1 parent cce2577 commit fdadc57
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 28 deletions.
2 changes: 1 addition & 1 deletion packages/desktop/components/ProposalCard.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { onMount } from 'svelte'
import { EventStatus } from '@iota/sdk/out/types'
import { ProposalStatusInfo } from '@components'
import { ProposalStatusInfo } from '@views/governance'
import { Text } from '@ui'
import { FontWeight } from '@ui/enums'
import { TooltipIcon, IconName } from '@bloomwalletio/ui'
Expand Down
1 change: 0 additions & 1 deletion packages/desktop/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export { default as ProposalAnswer } from './ProposalAnswer.svelte'
export { default as ProposalCard } from './ProposalCard.svelte'
export { default as ProposalsDetails } from './ProposalsDetails.svelte'
export { default as ProposalQuestion } from './ProposalQuestion.svelte'
export { default as ProposalStatusInfo } from './ProposalStatusInfo.svelte'
export { default as ProposalStatusTimelineTooltip } from './ProposalStatusTimelineTooltip.svelte'
export { default as SidebarTab } from './SidebarTab.svelte'
export { default as StatusTile, type StatusTileProps } from './StatusTile.svelte'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
<script lang="ts">
import { ProposalStatusTimelineTooltip } from '@components'
import { InformationTooltip, ProposalStatusPill } from '@ui'
import { Position } from '@ui/enums'
import { IProposal } from '@contexts/governance/interfaces'
import { localize } from '@core/i18n'
import { ProposalError } from '@lib/contexts/governance'
export let proposal: IProposal
export let position: Position = Position.Right
export let placement: 'top' | 'bottom' | 'left' | 'right' = 'right'
let anchor: HTMLElement
let isTooltipVisible = false
Expand Down Expand Up @@ -51,14 +50,14 @@
{#if proposal?.error}
{@const { title, body } = getProposalErrorText(proposal)}
{#if title && body}
<InformationTooltip {anchor} {position} {title} {body} />
<InformationTooltip {anchor} {placement} {title} {body} />
{/if}
{:else}
<ProposalStatusTimelineTooltip
bind:anchor
milestones={proposal.milestones}
status={proposal?.status}
{position}
position={placement}
/>
{/if}
{/if}
1 change: 1 addition & 0 deletions packages/desktop/views/governance/components/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as ProposalStatusInfo } from './ProposalStatusInfo.svelte'
1 change: 1 addition & 0 deletions packages/desktop/views/governance/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './components'
37 changes: 21 additions & 16 deletions packages/shared/src/components/InformationTooltip.svelte
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
<script lang="ts">
import { Text, Tooltip } from '@ui'
import { TextType } from './enums'
import { Popover, Text, type TextColor } from '@bloomwalletio/ui'
export let title: string = ''
export let body: string = ''
export let titleColor: TextColor | undefined = undefined
export let bodyColor: TextColor | undefined = undefined
</script>

<Tooltip {...$$restProps}>
<div class="flex flex-col text-left space-y-2">
{#if title}
<Text type={TextType.h4} color={$$restProps?.titleColor ?? undefined}>
{title}
</Text>
{/if}
{#if body}
<Text type={TextType.p} color={$$restProps?.bodyColor ?? undefined}>
{body}
</Text>
{/if}
</div>
</Tooltip>
<Popover
showArrow
event="hover"
class="shadow-elevation-4 p-4 rounded-xl flex flex-col text-left space-y-2 max-w-[15rem]"
{...$$restProps}
>
{#if title}
<Text type="h6" textColor={titleColor}>
{title}
</Text>
{/if}
{#if body}
<Text textColor={bodyColor} fontWeight="medium">
{body}
</Text>
{/if}
</Popover>
4 changes: 2 additions & 2 deletions packages/shared/src/components/atoms/MenuItem.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import { Icon, Text, Spinner, Position, InformationTooltip } from '@ui'
import { Icon, Text, Spinner, InformationTooltip } from '@ui'
import { Icon as IconEnum } from '@auxiliary/icon'
export let icon: string = ''
Expand Down Expand Up @@ -66,7 +66,7 @@
</button>

{#if showTooltip}
<InformationTooltip anchor={menuItem} position={Position.Right} body={tooltip} />
<InformationTooltip anchor={menuItem} body={tooltip} />
{/if}

<style lang="scss">
Expand Down
6 changes: 2 additions & 4 deletions packages/shared/src/components/inputs/OptionalInput.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import { onMount } from 'svelte'
import { fade } from 'svelte/transition'
import { ClosableInput, AddInputButton, FontWeight, InformationTooltip } from '@ui'
import { Position } from '@ui/enums'
export let label: string = ''
export let description: string = ''
Expand Down Expand Up @@ -64,11 +63,10 @@
<tooltip-container transition:fade={{ duration: 100 }}>
<InformationTooltip
anchor={buttonElement}
position={Position.Right}
title={label}
titleColor="gray-900"
titleColor="primary"
body={description}
bodyColor="gray-700"
bodyColor="secondary"
/>
</tooltip-container>
{/if}
Expand Down

0 comments on commit fdadc57

Please sign in to comment.