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

Added transactions table styling #30

Merged
merged 4 commits into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

- [Added transactions table styling](https://github.com/multiversx/mx-sdk-dapp-core-ui/pull/30)
- [Added react output config](https://github.com/multiversx/mx-sdk-dapp-core-ui/pull/29)
- [Added Trim and CopyButton components](https://github.com/multiversx/mx-sdk-dapp-core-ui/pull/28)
- [Added transaction account](https://github.com/multiversx/mx-sdk-dapp-core-ui/pull/27)
Expand Down
21 changes: 3 additions & 18 deletions src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,11 @@ export namespace Components {
"showLockedAccounts": boolean;
}
interface TransactionAccountName {
"address": string;
"class"?: string;
"dataTestId"?: string;
"description": string;
"name": string;
"name"?: string;
}
interface TransactionAge {
"age": string;
Expand All @@ -136,10 +137,6 @@ export namespace Components {
"class"?: string;
"method": string;
}
interface TransactionRow {
"class"?: string;
"transaction": ITransactionsTableRow;
}
interface TransactionShards {
"class"?: string;
"transaction": ITransactionsTableRow;
Expand Down Expand Up @@ -406,12 +403,6 @@ declare global {
prototype: HTMLTransactionMethodElement;
new (): HTMLTransactionMethodElement;
};
interface HTMLTransactionRowElement extends Components.TransactionRow, HTMLStencilElement {
}
var HTMLTransactionRowElement: {
prototype: HTMLTransactionRowElement;
new (): HTMLTransactionRowElement;
};
interface HTMLTransactionShardsElement extends Components.TransactionShards, HTMLStencilElement {
}
var HTMLTransactionShardsElement: {
Expand Down Expand Up @@ -525,7 +516,6 @@ declare global {
"transaction-hash": HTMLTransactionHashElement;
"transaction-icon": HTMLTransactionIconElement;
"transaction-method": HTMLTransactionMethodElement;
"transaction-row": HTMLTransactionRowElement;
"transaction-shards": HTMLTransactionShardsElement;
"transaction-toast": HTMLTransactionToastElement;
"transaction-toast-content": HTMLTransactionToastContentElement;
Expand Down Expand Up @@ -621,6 +611,7 @@ declare namespace LocalJSX {
"showLockedAccounts"?: boolean;
}
interface TransactionAccountName {
"address"?: string;
"class"?: string;
"dataTestId"?: string;
"description"?: string;
Expand Down Expand Up @@ -648,10 +639,6 @@ declare namespace LocalJSX {
"class"?: string;
"method"?: string;
}
interface TransactionRow {
"class"?: string;
"transaction"?: ITransactionsTableRow;
}
interface TransactionShards {
"class"?: string;
"transaction"?: ITransactionsTableRow;
Expand Down Expand Up @@ -730,7 +717,6 @@ declare namespace LocalJSX {
"transaction-hash": TransactionHash;
"transaction-icon": TransactionIcon;
"transaction-method": TransactionMethod;
"transaction-row": TransactionRow;
"transaction-shards": TransactionShards;
"transaction-toast": TransactionToast;
"transaction-toast-content": TransactionToastContent;
Expand Down Expand Up @@ -772,7 +758,6 @@ declare module "@stencil/core" {
"transaction-hash": LocalJSX.TransactionHash & JSXBase.HTMLAttributes<HTMLTransactionHashElement>;
"transaction-icon": LocalJSX.TransactionIcon & JSXBase.HTMLAttributes<HTMLTransactionIconElement>;
"transaction-method": LocalJSX.TransactionMethod & JSXBase.HTMLAttributes<HTMLTransactionMethodElement>;
"transaction-row": LocalJSX.TransactionRow & JSXBase.HTMLAttributes<HTMLTransactionRowElement>;
"transaction-shards": LocalJSX.TransactionShards & JSXBase.HTMLAttributes<HTMLTransactionShardsElement>;
"transaction-toast": LocalJSX.TransactionToast & JSXBase.HTMLAttributes<HTMLTransactionToastElement>;
"transaction-toast-content": LocalJSX.TransactionToastContent & JSXBase.HTMLAttributes<HTMLTransactionToastContentElement>;
Expand Down
5 changes: 3 additions & 2 deletions src/components/copy-button/copy-button.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { Component, Prop, h, State } from '@stencil/core';
import { faCheck, faCopy, IconDefinition } from '@fortawesome/free-solid-svg-icons';
import { copyToClipboard } from 'utils/copyToClipboard';
import classNames from 'classnames';

@Component({
tag: 'copy-button',
styleUrl: 'copy-button.css',
shadow: true,
})
export class CopyButton {
@Prop() class?: string = 'copy-button';
@Prop() class?: string;
@Prop() copyIcon: IconDefinition = faCopy;
@Prop() successIcon: IconDefinition = faCheck;
@Prop() text: string;
Expand Down Expand Up @@ -43,7 +44,7 @@ export class CopyButton {

render() {
return (
<a href="/#" class={this.class} onClick={this.handleClick}>
<a href="/#" class={classNames(this.class, 'copy-button')} onClick={this.handleClick}>
<fa-icon icon={this.isSuccess ? this.successIcon : this.copyIcon}></fa-icon>
</a>
);
Expand Down
12 changes: 6 additions & 6 deletions src/components/copy-button/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@

## Properties

| Property | Attribute | Description | Type | Default |
| ------------- | --------- | ----------- | ---------------- | --------------- |
| `class` | `class` | | `string` | `'copy-button'` |
| `copyIcon` | -- | | `IconDefinition` | `faCopy` |
| `successIcon` | -- | | `IconDefinition` | `faCheck` |
| `text` | `text` | | `string` | `undefined` |
| Property | Attribute | Description | Type | Default |
| ------------- | --------- | ----------- | ---------------- | ----------- |
| `class` | `class` | | `string` | `undefined` |
| `copyIcon` | -- | | `IconDefinition` | `faCopy` |
| `successIcon` | -- | | `IconDefinition` | `faCheck` |
| `text` | `text` | | `string` | `undefined` |


## Dependencies
Expand Down
3 changes: 3 additions & 0 deletions src/components/explorer-link/explorer-link.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.explorer-link {
text-decoration: none;
}
10 changes: 4 additions & 6 deletions src/components/explorer-link/explorer-link.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { Component, Prop, h, Element, State } from '@stencil/core';
import { getIconHtmlFromIconDefinition } from 'utils/icons/getIconHtmlFromIconDefinition';
import { IconDefinition, faArrowUpRightFromSquare } from '@fortawesome/free-solid-svg-icons';
import classNames from 'classnames';

@Component({
tag: 'explorer-link',
styleUrl: 'explorer-link.css',
shadow: true,
})
export class ExplorerLink {
@Prop() class: string = 'explorer-link';
@Prop() class: string;
@Prop() dataTestId?: string;
@Prop() icon?: IconDefinition;
@Prop() link: string;
Expand All @@ -22,11 +22,9 @@ export class ExplorerLink {
}

render() {
const icon = getIconHtmlFromIconDefinition(this.icon ?? faArrowUpRightFromSquare);

return (
<a data-testid={this.dataTestId} href={this.link} target="_blank" class={this.class} rel="noreferrer">
{this.hasSlotContent ? <slot name="content"></slot> : this.text ?? <span innerHTML={icon}></span>}
<a data-testid={this.dataTestId} href={this.link} target="_blank" class={classNames(this.class, 'explorer-link')} rel="noreferrer">
{this.hasSlotContent ? <slot name="content"></slot> : this.text ?? <fa-icon icon={this.icon ?? faArrowUpRightFromSquare}></fa-icon>}
</a>
);
}
Expand Down
19 changes: 12 additions & 7 deletions src/components/explorer-link/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@

## Properties

| Property | Attribute | Description | Type | Default |
| ------------ | -------------- | ----------- | ---------------- | ----------------- |
| `class` | `class` | | `string` | `'explorer-link'` |
| `dataTestId` | `data-test-id` | | `string` | `undefined` |
| `icon` | -- | | `IconDefinition` | `undefined` |
| `link` | `link` | | `string` | `undefined` |
| `text` | `text` | | `string` | `undefined` |
| Property | Attribute | Description | Type | Default |
| ------------ | -------------- | ----------- | ---------------- | ----------- |
| `class` | `class` | | `string` | `undefined` |
| `dataTestId` | `data-test-id` | | `string` | `undefined` |
| `icon` | -- | | `IconDefinition` | `undefined` |
| `link` | `link` | | `string` | `undefined` |
| `text` | `text` | | `string` | `undefined` |


## Dependencies
Expand All @@ -25,9 +25,14 @@
- [transaction-shards](../transactions-table/components/transaction-shards)
- [transaction-value](../transactions-table/components/transaction-value)

### Depends on

- [fa-icon](../fa-icon)

### Graph
```mermaid
graph TD;
explorer-link --> fa-icon
transaction-account --> explorer-link
transaction-hash --> explorer-link
transaction-shards --> explorer-link
Expand Down
16 changes: 4 additions & 12 deletions src/components/explorer-link/tests/explorer-link.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { newSpecPage } from '@stencil/core/testing';
import { ExplorerLink } from '../explorer-link';
import { faCheck } from '@fortawesome/free-solid-svg-icons';
import * as iconUtils from 'utils/icons/getIconHtmlFromIconDefinition';

describe('ExplorerLink', () => {
it('renders with default props', async () => {
Expand All @@ -13,9 +12,7 @@ describe('ExplorerLink', () => {
<explorer-link link="https://example.com">
<mock:shadow-root>
<a href="https://example.com" target="_blank" class="explorer-link" rel="noreferrer">
<span>
<svg aria-hidden="true" class="fa-arrow-up-right-from-square svg-inline--fa" data-icon="arrow-up-right-from-square" data-prefix="fas" focusable="false" role="img" viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg"><path d="M320 0c-17.7 0-32 14.3-32 32s14.3 32 32 32l82.7 0L201.4 265.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L448 109.3l0 82.7c0 17.7 14.3 32 32 32s32-14.3 32-32l0-160c0-17.7-14.3-32-32-32L320 0zM80 32C35.8 32 0 67.8 0 112L0 432c0 44.2 35.8 80 80 80l320 0c44.2 0 80-35.8 80-80l0-112c0-17.7-14.3-32-32-32s-32 14.3-32 32l0 112c0 8.8-7.2 16-16 16L80 448c-8.8 0-16-7.2-16-16l0-320c0-8.8 7.2-16 16-16l112 0c17.7 0 32-14.3 32-32s-14.3-32-32-32L80 32z" fill="currentColor"></path></svg>
</span>
<fa-icon></fa-icon>
</a>
</mock:shadow-root>
</explorer-link>
Expand Down Expand Up @@ -46,20 +43,15 @@ describe('ExplorerLink', () => {
expect(page.root).toEqualHtml(`
<explorer-link link="https://example.com" class="custom-class">
<mock:shadow-root>
<a href="https://example.com" target="_blank" class="custom-class" rel="noreferrer">
<span>
<svg aria-hidden="true" class="fa-arrow-up-right-from-square svg-inline--fa" data-icon="arrow-up-right-from-square" data-prefix="fas" focusable="false" role="img" viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg"><path d="M320 0c-17.7 0-32 14.3-32 32s14.3 32 32 32l82.7 0L201.4 265.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L448 109.3l0 82.7c0 17.7 14.3 32 32 32s32-14.3 32-32l0-160c0-17.7-14.3-32-32-32L320 0zM80 32C35.8 32 0 67.8 0 112L0 432c0 44.2 35.8 80 80 80l320 0c44.2 0 80-35.8 80-80l0-112c0-17.7-14.3-32-32-32s-32 14.3-32 32l0 112c0 8.8-7.2 16-16 16L80 448c-8.8 0-16-7.2-16-16l0-320c0-8.8 7.2-16 16-16l112 0c17.7 0 32-14.3 32-32s-14.3-32-32-32L80 32z" fill="currentColor"></path></svg>
</span>
<a href="https://example.com" target="_blank" class="custom-class explorer-link" rel="noreferrer">
<fa-icon></fa-icon>
</a>
</mock:shadow-root>
</explorer-link>
`);
});

it('renders with custom icon', async () => {
const mockIconHtml = '<i class="fa-check"></i>';
jest.spyOn(iconUtils, 'getIconHtmlFromIconDefinition').mockReturnValue(mockIconHtml);

const page = await newSpecPage({
components: [ExplorerLink],
html: '<explorer-link link="https://example.com"></explorer-link>',
Expand All @@ -72,7 +64,7 @@ describe('ExplorerLink', () => {
<explorer-link link="https://example.com">
<mock:shadow-root>
<a href="https://example.com" target="_blank" class="explorer-link" rel="noreferrer">
<span>${mockIconHtml}</span>
<fa-icon></fa-icon>
</a>
</mock:shadow-root>
</explorer-link>
Expand Down
6 changes: 6 additions & 0 deletions src/components/fa-icon/fa-icon.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.fa-icon .svg-inline--fa {
align-items: center;
display: flex;
height: 1rem;
justify-content: center;
}
6 changes: 4 additions & 2 deletions src/components/fa-icon/fa-icon.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { Component, Prop, h } from '@stencil/core';
import { getIconHtmlFromIconDefinition } from 'utils/icons/getIconHtmlFromIconDefinition';
import { IconDefinition } from '@fortawesome/free-solid-svg-icons';
import classNames from 'classnames';

@Component({
tag: 'fa-icon',
styleUrl: 'fa-icon.css',
shadow: true,
})
export class FaIcon {
@Prop() class?: string = 'fa-icon';
@Prop() class?: string;
@Prop() icon: IconDefinition;
@Prop() description?: string;

Expand All @@ -18,6 +20,6 @@ export class FaIcon {

const iconHtml = getIconHtmlFromIconDefinition(this.icon);

return <i class={this.class} innerHTML={iconHtml} title={this.description}></i>;
return <i class={classNames(this.class, 'fa-icon')} innerHTML={iconHtml} title={this.description}></i>;
}
}
4 changes: 3 additions & 1 deletion src/components/fa-icon/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

| Property | Attribute | Description | Type | Default |
| ------------- | ------------- | ----------- | ---------------- | ----------- |
| `class` | `class` | | `string` | `'fa-icon'` |
| `class` | `class` | | `string` | `undefined` |
| `description` | `description` | | `string` | `undefined` |
| `icon` | -- | | `IconDefinition` | `undefined` |

Expand All @@ -19,6 +19,7 @@
### Used by

- [copy-button](../copy-button)
- [explorer-link](../explorer-link)
- [transaction-account](../transactions-table/components/transaction-account)
- [transaction-icon](../transactions-table/components/transaction-icon)
- [transaction-value](../transactions-table/components/transaction-value)
Expand All @@ -27,6 +28,7 @@
```mermaid
graph TD;
copy-button --> fa-icon
explorer-link --> fa-icon
transaction-account --> fa-icon
transaction-icon --> fa-icon
transaction-value --> fa-icon
Expand Down
5 changes: 5 additions & 0 deletions src/components/format-amount/format-amount.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
.format-amount {
align-items: center;
}

.int-amount {
color: inherit;
}
Expand All @@ -8,4 +12,5 @@

.symbol {
color: inherit;
margin-left: 0.25rem;
}
3 changes: 2 additions & 1 deletion src/components/format-amount/format-amount.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Component, Prop, h } from '@stencil/core';
import { DataTestIdsEnum } from 'constants/dataTestIds.enum';
razvantomegea marked this conversation as resolved.
Show resolved Hide resolved
import classNames from 'classnames';

@Component({
tag: 'format-amount',
Expand Down Expand Up @@ -31,7 +32,7 @@ export class FormatAmount {

private renderValid() {
return (
<span data-testid={this.dataTestId} class={this.class}>
<span data-testid={this.dataTestId} class={classNames(this.class, 'format-amount')}>
<span class="int-amount" data-testid={DataTestIdsEnum.formatAmountInt}>
{this.valueInteger}
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@

## Properties

| Property | Attribute | Description | Type | Default |
| ------------- | -------------- | ----------- | -------- | ---------------------------- |
| `class` | `class` | | `string` | `'transaction-account-name'` |
| `dataTestId` | `data-test-id` | | `string` | `undefined` |
| `description` | `description` | | `string` | `undefined` |
| `name` | `name` | | `string` | `undefined` |
| Property | Attribute | Description | Type | Default |
| ------------- | -------------- | ----------- | -------- | ----------- |
| `address` | `address` | | `string` | `undefined` |
| `class` | `class` | | `string` | `undefined` |
| `dataTestId` | `data-test-id` | | `string` | `undefined` |
| `description` | `description` | | `string` | `undefined` |
| `name` | `name` | | `string` | `undefined` |


## Dependencies
Expand Down
Loading
Loading