Skip to content

Commit 28feb74

Browse files
iuliacimpeanuMiroMargineanuarhtudormorar
authored
0.0.36 (#251)
* Storybook Deployment Setup (#248) * Added Storybook deployment workflow * Added secrets references * Added workflow dependency to run the GitHub action * Fixed workflow build * Fixed workflow build * Fixed workflow build * Fixed workflow build * Fixed workflow build * Fixed storybook build rendering on server * Fixed type in main * Added comments to converter * Updated CHANGELOG.md * Updated deployment branch * Fixed build * Removed lit * Fixed build * Updated deployment branch * Updated deployment branch * Remove lit --------- Co-authored-by: Tudor Morar <[email protected]> * Refactor components in transactions table (#243) * Updated styles * Removed unused styles * Removed unused styles * Updated styles * Updated CHANGELOG.md * Updated icons * Removed unused icons * Updated styles * Updated styles * Updated styles * Updated styles * Updated shards arrow styles * Added icons to replace Fontawesome * Updated styles * Fixed tests * Updated styles on transactions table * Refactored FontAwesome icons * Fixed test * Updated scrollbar styles * Fixes after review. * Removed FontAwesome packages * Updated icons * Fixed tests * Fixes * Fixes. * Fixes * Refactored transaction-age * Updated changelog * Fixed path * Removed transaction-direction-badge component not used * Refactored transaction-hash comp * Refactored components from transactions-table * Refactored classNames * Updated changelog * Fixed tests * Fixed tests * Updated TransactionIcon * Updated TransactionIcon * Updated default icon * Fixes * Fixes --------- Co-authored-by: Miro Mărgineanu <[email protected]> * Updated icons type (#250) * Fixed icon name * Fixed name * Updated truncate * Updated changelog * Updated icons * Fixed tests * Fixes * Fixed casts * Fixed errors * v0.0.36 --------- Co-authored-by: Miro <[email protected]> Co-authored-by: Tudor Morar <[email protected]>
1 parent f0d95d1 commit 28feb74

File tree

75 files changed

+2393
-2384
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+2393
-2384
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Deploy Storybook
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- 'src/**'
8+
- '.storybook/**'
9+
- 'package.json'
10+
- '.github/workflows/deploy-storybook.yml'
11+
workflow_dispatch:
12+
13+
jobs:
14+
build-and-deploy:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
with:
20+
ref: ${{ github.ref }}
21+
clean: true
22+
23+
- name: Set up Node.js
24+
uses: actions/setup-node@v4
25+
with:
26+
node-version: 22
27+
28+
- name: Setup Yarn
29+
run: npm install -g yarn
30+
31+
- name: Install Dependencies
32+
run: yarn install --frozen-lockfile
33+
34+
- name: Build Storybook (includes Stencil build)
35+
run: yarn run storybook-build
36+
37+
- name: Configure AWS Credentials
38+
uses: aws-actions/configure-aws-credentials@v4
39+
with:
40+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
41+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
42+
aws-region: 'us-east-1'
43+
44+
- name: Deploy to S3 bucket
45+
run: aws s3 sync ./storybook-static/ s3://${{ secrets.AWS_S3_BUCKET }} --delete --acl public-read
46+
47+
- name: Set proper MIME types and headers for all files
48+
run: |
49+
# JavaScript files with proper CORS
50+
aws s3 cp s3://${{ secrets.AWS_S3_BUCKET }}/ s3://${{ secrets.AWS_S3_BUCKET }}/ --recursive --exclude "*" --include "*.js" --content-type "application/javascript" --metadata-directive REPLACE --acl public-read --cache-control "public, max-age=31536000"
51+
# CSS files
52+
aws s3 cp s3://${{ secrets.AWS_S3_BUCKET }}/ s3://${{ secrets.AWS_S3_BUCKET }}/ --recursive --exclude "*" --include "*.css" --content-type "text/css" --metadata-directive REPLACE --acl public-read --cache-control "public, max-age=31536000"
53+
# JSON files
54+
aws s3 cp s3://${{ secrets.AWS_S3_BUCKET }}/ s3://${{ secrets.AWS_S3_BUCKET }}/ --recursive --exclude "*" --include "*.json" --content-type "application/json" --metadata-directive REPLACE --acl public-read
55+
# HTML files (iframe.html, etc.)
56+
aws s3 cp s3://${{ secrets.AWS_S3_BUCKET }}/ s3://${{ secrets.AWS_S3_BUCKET }}/ --recursive --exclude "*" --include "*.html" --content-type "text/html" --metadata-directive REPLACE --acl public-read --cache-control "no-cache"
57+
58+
- name: No-cache index.html
59+
run: aws s3 cp s3://${{ secrets.AWS_S3_BUCKET }}/index.html s3://${{ secrets.AWS_S3_BUCKET }}/index.html --metadata-directive REPLACE --cache-control max-age=0,no-cache,no-store,must-revalidate --content-type text/html --acl public-read
60+
61+
- name: Slack Notification
62+
uses: rtCamp/action-slack-notify@master
63+
env:
64+
SLACK_ICON_EMOJI: ':books:'
65+
SLACK_USERNAME: mx-sdk-dapp-ui
66+
SLACK_TITLE: 'Storybook'
67+
SLACK_MESSAGE: 'Successfully deployed to: https://${{ secrets.AWS_S3_BUCKET }}'
68+
SLACK_COLOR: 'good'
69+
SLACK_FOOTER: 'Deployed from branch: ${{ github.ref_name }}'
70+
MSG_MINIMAL: false
71+
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}

.storybook/jsxToHtml.ts

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
// Interface representing a Stencil VNode structure
2+
interface VNodeStencil {
3+
$tag$?: string;
4+
$attrs$?: Record<string, unknown> | null;
5+
$children$?: Array<VNodeStencil | VNodeLike | string> | null;
6+
$text$?: string | null;
7+
}
8+
9+
// Interface representing a React-like VNode structure
10+
interface VNodeLike {
11+
type?: string | ((...args: unknown[]) => unknown);
12+
props?: Record<string, unknown> & { children?: Array<VNodeLike | string> | VNodeLike | string };
13+
children?: Array<VNodeLike | string> | VNodeLike | string;
14+
}
15+
16+
// Escapes HTML special characters to prevent XSS attacks
17+
const escapeHtml = (value: string): string =>
18+
value
19+
.replace(/&/g, '&amp;')
20+
.replace(/</g, '&lt;')
21+
.replace(/>/g, '&gt;')
22+
.replace(/"/g, '&quot;')
23+
.replace(/'/g, '&#39;');
24+
25+
// Converts attribute object to HTML attribute string
26+
const attrsToString = (attrs: Record<string, unknown> | null | undefined): string => {
27+
if (!attrs) {
28+
return '';
29+
}
30+
31+
return Object.entries(attrs)
32+
.filter(([, v]) => v !== undefined && v !== null && v !== false)
33+
.map(([k, v]) => (v === true ? k : `${k}="${escapeHtml(String(v))}"`))
34+
.join(' ');
35+
};
36+
37+
// Normalizes children to a consistent array format
38+
const normalizeChildren = (children: unknown): Array<VNodeStencil | VNodeLike | string> => {
39+
if (children == null) {
40+
return [];
41+
}
42+
43+
if (Array.isArray(children)) {
44+
return children as Array<VNodeStencil | VNodeLike | string>;
45+
}
46+
47+
return [children as VNodeStencil | VNodeLike | string];
48+
};
49+
50+
// Renders a Stencil VNode to HTML string
51+
const renderStencil = (node: VNodeStencil): string => {
52+
if (node.$text$ != null) {
53+
return escapeHtml(String(node.$text$));
54+
}
55+
56+
const tag = node.$tag$ || 'div';
57+
const attrs = attrsToString(node.$attrs$ || undefined);
58+
const children = (node.$children$ || []).map(renderAny).join('');
59+
const attrsStr = attrs ? ` ${attrs}` : '';
60+
61+
return `<${tag}${attrsStr}>${children}</${tag}>`;
62+
};
63+
64+
// Renders a React-like VNode to HTML string
65+
const renderLike = (node: VNodeLike): string => {
66+
const tag = typeof node.type === 'string' ? node.type : 'div';
67+
const props = node.props || {};
68+
const { children, ...rest } = props as Record<string, unknown> & { children?: unknown };
69+
const attrs = attrsToString(rest);
70+
const childrenArr = normalizeChildren(children ?? node.children);
71+
const childrenStr = childrenArr.map(renderAny).join('');
72+
const attrsStr = attrs ? ` ${attrs}` : '';
73+
74+
return `<${tag}${attrsStr}>${childrenStr}</${tag}>`;
75+
};
76+
77+
// Main export function that converts JSX to HTML string
78+
export const renderJsxToHtml = (node: unknown): string => renderAny(node);
79+
80+
// Renders any node type to HTML string with type detection
81+
const renderAny = (node: unknown): string => {
82+
if (node == null || node === false) {
83+
return '';
84+
}
85+
86+
if (typeof node === 'string' || typeof node === 'number') {
87+
return escapeHtml(String(node));
88+
}
89+
90+
// Heuristics for detecting node types
91+
if (typeof node === 'object') {
92+
const o = node as Record<string, unknown>;
93+
94+
// Check for Stencil VNode
95+
if ('$tag$' in o || '$text$' in o || '$children$' in o) {
96+
return renderStencil(node as VNodeStencil);
97+
}
98+
99+
// Check for React-like VNode
100+
if ('type' in o || 'props' in o || 'children' in o) {
101+
return renderLike(node as VNodeLike);
102+
}
103+
}
104+
105+
// Fallback for unknown node types
106+
return escapeHtml(String(node));
107+
};

.storybook/main.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,16 @@ const config = {
22
stories: ['../src/**/*.stories.@(js|jsx|ts|tsx)'],
33
addons: ['@storybook/addon-links', '@storybook/addon-docs'],
44
framework: {
5-
name: '@stencil/storybook-plugin',
5+
name: '@storybook/html-vite',
66
},
7+
managerHead: head => `
8+
${head}
9+
<base href="./" />
10+
`,
11+
previewHead: head => `
12+
${head}
13+
<base href="./" />
14+
`,
715
};
816

917
export default config;

.storybook/preview.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/** @jsx h */
22
import { h } from '@stencil/core';
3-
import type { Preview } from '@stencil/storybook-plugin';
3+
import type { Preview } from '@storybook/html-vite';
4+
import { renderJsxToHtml } from './jsxToHtml';
45

56
import { defineCustomElements } from '../dist/web-components';
67

@@ -11,11 +12,12 @@ import './tailwind.css';
1112
defineCustomElements();
1213

1314
export const decorators: Preview['decorators'] = [
14-
(Story, context) => (
15-
<div data-mvx-theme={`mvx:${context.globals.backgrounds.value}-theme`}>
16-
<Story />
17-
</div>
18-
),
15+
(Story, context) =>
16+
renderJsxToHtml(
17+
<div data-mvx-theme={`mvx:${context.globals.backgrounds.value}-theme`}>
18+
<Story />
19+
</div>,
20+
),
1921
];
2022

2123
export const initialGlobals: Preview['initialGlobals'] = {

.storybook/public/CNAME

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
sdk-dapp-ui.multiversx.com

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [[0.0.36](https://github.com/multiversx/mx-sdk-dapp-ui/pull/251)] - 2025-10-15
11+
12+
- [Updated icons type](https://github.com/multiversx/mx-sdk-dapp-ui/pull/250)
13+
14+
- [Added the Storybook as a live server deployment](https://github.com/multiversx/mx-sdk-dapp-ui/pull/248)
15+
16+
- [Refactor components in transactions table](https://github.com/multiversx/mx-sdk-dapp-ui/pull/243)
17+
1018
## [[0.0.35](https://github.com/multiversx/mx-sdk-dapp-ui/pull/246)] - 2025-10-10
1119

1220
- [Added passkey provider](https://github.com/multiversx/mx-sdk-dapp-ui/pull/242)

package.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@multiversx/sdk-dapp-ui",
3-
"version": "0.0.35",
3+
"version": "0.0.36",
44
"description": "A library to hold UI components for a dApp on the MultiversX blockchain",
55
"author": "MultiversX",
66
"license": "MIT",
@@ -84,8 +84,9 @@
8484
"build:dev": "stencil build --dev",
8585
"build": "stencil build --prod && tsc -p tsconfig.utils.json && tsc-alias -p tsconfig.utils.json",
8686
"start": "yarn run build:dev --watch --serve",
87-
"storybook-tailwind": "npx ts-node .storybook/generate-safelist.ts && npx @tailwindcss/cli -i src/global/tailwind.css -o .storybook/tailwind.css --content '.storybook/tailwind-safelist.html' && rm -f .storybook/tailwind-safelist.html",
88-
"storybook": "yarn run storybook-tailwind && storybook dev -p 6006 --no-open"
87+
"storybook-build-tailwind": "npx ts-node .storybook/generate-safelist.ts && npx @tailwindcss/cli -i src/global/tailwind.css -o .storybook/tailwind.css --content '.storybook/tailwind-safelist.html' && rm -f .storybook/tailwind-safelist.html",
88+
"storybook-dev": "yarn run build && yarn run storybook-build-tailwind && storybook dev -p 6006 --no-open",
89+
"storybook-build": "yarn run build && yarn run storybook-build-tailwind && storybook build"
8990
},
9091
"dependencies": {
9192
"@stencil/core": "^4.36.2",
@@ -103,6 +104,8 @@
103104
"@stencil/storybook-plugin": "^0.4.2",
104105
"@storybook/addon-docs": "9.1.7",
105106
"@storybook/addon-links": "9.1.7",
107+
"@storybook/html": "^9.1.10",
108+
"@storybook/html-vite": "^9.1.10",
106109
"@tailwindcss/cli": "4.0.17",
107110
"@tailwindcss/postcss": "4.1.3",
108111
"@types/jest": "^29.5.14",
@@ -129,4 +132,4 @@
129132
"typescript": "^5.7.3",
130133
"vite": "^7.0.6"
131134
}
132-
}
135+
}

0 commit comments

Comments
 (0)