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 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
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
112 changes: 15 additions & 97 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,106 +1,24 @@
import globals from 'globals';
import pluginJs from '@eslint/js';
import tseslint from 'typescript-eslint';
import importPlugin from 'eslint-plugin-import';
import prettierPlugin from 'eslint-plugin-prettier';
import jestPlugin from 'eslint-plugin-jest';
import simpleImportSort from 'eslint-plugin-simple-import-sort';
import typescriptParser from '@typescript-eslint/parser';
import typescriptPlugin from '@typescript-eslint/eslint-plugin';

/** @type {import('eslint').Linter.Config[]} */
export default [
{
files: ['**/*.{js,mjs,cjs,ts,tsx}', '**/*.{test,spec}.{js,ts,tsx}'],
languageOptions: {
globals: {
...globals.browser,
...globals.node,
...globals.jest
},
parser: tseslint.parser,
parserOptions: {
ecmaVersion: 2021,
sourceType: 'module',
ecmaFeatures: {
jsx: true
},
project: './tsconfig.json'
}
},
files: ['src/**/*.{ts,tsx}'],
plugins: {
import: importPlugin,
prettier: prettierPlugin,
jest: jestPlugin,
'@typescript-eslint': tseslint.plugin
},
settings: {
'import/parsers': {
'@typescript-eslint/parser': ['.ts', '.tsx']
},
'import/resolver': {
node: {
extensions: ['.js', '.jsx', '.ts', '.tsx'],
moduleDirectory: ['node_modules', 'src/']
},
typescript: {
alwaysTryTypes: true
}
}
'@typescript-eslint': typescriptPlugin,
'simple-import-sort': simpleImportSort
},
rules: {
...jestPlugin.configs.recommended.rules,
...pluginJs.configs.recommended.rules,
...tseslint.configs.recommended.rules,
'import/order': [
'warn',
{
groups: ['builtin', 'external', 'internal'],
pathGroups: [
{
pattern: 'react',
group: 'external',
position: 'before'
}
],
'newlines-between': 'ignore',
alphabetize: {
order: 'asc',
caseInsensitive: true
}
}
],
'prettier/prettier': ['error', { endOfLine: 'lf' }],
'@typescript-eslint/indent': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-use-before-define': [
'error',
{ functions: false, classes: false }
],
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_'
}
],
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'linebreak-style': ['error', 'unix'],
quotes: ['error', 'single'],
semi: ['error', 'always'],
'no-unused-vars': ['off'],
'no-prototype-builtins': 'off',
'jest/no-mocks-import': 'off',
'no-async-promise-executor': 'off',
'object-curly-newline': 'off',
'arrow-body-style': 'off',
'implicit-arrow-linebreak': 'off',
'func-names': 'off',
curly: ['error', 'all'],
'operator-linebreak': 'off',
'function-paren-newline': 'off',
'no-shadow': 'off',
'@typescript-eslint/no-shadow': 'off'
'simple-import-sort/imports': 'error',
'simple-import-sort/exports': 'error',
'@typescript-eslint/consistent-type-imports': 'error'
},
languageOptions: {
parser: typescriptParser,
parserOptions: {
project: true
}
}
}
];
12 changes: 10 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
"build": "stencil build",
"start": "stencil build --dev --watch --serve",
"test": "stencil test --spec --e2e",
"lint": "eslint src",
"lint:fix": "eslint src --fix",
"unpublish-verdaccio": "npm unpublish @multiversx/sdk-dapp-core-ui --force --registry http://localhost:4873",
"publish-verdaccio": "npm run unpublish-verdaccio && npm run build && npm publish --registry http://localhost:4873/",
"test.watch": "stencil test --spec --e2e --watchAll",
Expand All @@ -59,17 +61,23 @@
},
"devDependencies": {
"@stencil/core": "^4.22.3",
"@stencil/react-output-target": "0.8.2",
"@stencil/sass": "^3.0.12",
"@stencil/store": "2.0.16",
"@stencil/react-output-target": "0.8.2",
"@types/jest": "^29.5.14",
"@types/jsdom": "^21.1.1",
"@types/node": "^22.10.0",
"@typescript-eslint/eslint-plugin": "^8.23.0",
"@typescript-eslint/parser": "^8.23.0",
"eslint": "^9.19.0",
"eslint-plugin-simple-import-sort": "^12.1.1",
"globals": "^15.14.0",
"jest": "^29.7.0",
"jest-cli": "^29.7.0",
"jsdom": "^22.1.0",
"prettier": "3.2.5",
"puppeteer": "^23.9.0",
"rollup-plugin-node-polyfills": "^0.2.1"
"rollup-plugin-node-polyfills": "^0.2.1",
"typescript": "^5.7.3"
}
}
3 changes: 2 additions & 1 deletion src/common/generic-modal/generic-modal.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Component, Event, EventEmitter, Prop, VNode, h } from '@stencil/core';
import type { EventEmitter, VNode} from '@stencil/core';
import { Component, Event, h,Prop } from '@stencil/core';

@Component({
tag: 'generic-modal',
Expand Down
2 changes: 1 addition & 1 deletion src/common/generic-spinner/generic-spinner.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, h, Element } from '@stencil/core';
import { Component, Element,h } from '@stencil/core';

@Component({
tag: 'generic-spinner',
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
10 changes: 6 additions & 4 deletions src/components/copy-button/copy-button.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { Component, Prop, h, State } from '@stencil/core';
import { faCheck, faCopy, IconDefinition } from '@fortawesome/free-solid-svg-icons';
import type { IconDefinition } from '@fortawesome/free-solid-svg-icons';
import { faCheck, faCopy } from '@fortawesome/free-solid-svg-icons';
import { Component, h, Prop, State } from '@stencil/core';
import classNames from 'classnames';
import { copyToClipboard } from 'utils/copyToClipboard';

@Component({
Expand All @@ -8,7 +10,7 @@ import { copyToClipboard } from 'utils/copyToClipboard';
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 +45,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
5 changes: 3 additions & 2 deletions src/components/copy-button/tests/copy-button.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { newSpecPage } from '@stencil/core/testing';
import { CopyButton } from '../copy-button';
import * as copyUtils from 'utils/copyToClipboard';

import { CopyButton } from '../copy-button';

describe('CopyButton', () => {
it('renders with default props', async () => {
const page = await newSpecPage({
Expand Down Expand Up @@ -29,7 +30,7 @@ describe('CopyButton', () => {
expect(page.root).toEqualHtml(`
<copy-button class="custom-class" text="Copy me">
<mock:shadow-root>
<a href="/#" class="custom-class">
<a href="/#" class="custom-class copy-button">
<fa-icon></fa-icon>
</a>
</mock:shadow-root>
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;
}
15 changes: 7 additions & 8 deletions src/components/explorer-link/explorer-link.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
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 type { IconDefinition} from '@fortawesome/free-solid-svg-icons';
import { faArrowUpRightFromSquare } from '@fortawesome/free-solid-svg-icons';
import { Component, Element, h, Prop, State } from '@stencil/core';
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 +23,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
Loading