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

feat: migrate DisplayedPrice and create DisplayedPriceWithSymbol #361

Open
wants to merge 47 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
386f653
feat: [SC-25297] Migrate DisplayedPrice comp. to namekit-react
FrancoAguzzi Aug 21, 2024
3513deb
feat: [SC-25297] Update formattedPrice function to render different P…
FrancoAguzzi Aug 21, 2024
e8bd561
feat: [SC-25520] Create stories for DisplayedPriceWithAltText
FrancoAguzzi Aug 21, 2024
4352362
feat: [SC-25297] Optimize alt price and main price alignments | Creat…
FrancoAguzzi Aug 21, 2024
8cc1b5a
feat: [SC-25520] Create changesets for Price components creation PR
FrancoAguzzi Aug 21, 2024
98019e2
feat: [SC-25520] Add DisplayedPriceWithAltPrice export to namekit-rea…
FrancoAguzzi Aug 21, 2024
b967b85
feat: [SC-25297] Created examples of DisplayedPrice for each Currency…
FrancoAguzzi Aug 21, 2024
b5102af
feat: [SC-25297] Delete DisplayedPriceWithAltPrice and update Display…
FrancoAguzzi Aug 22, 2024
9be7ba6
feat: [SC-25297] Set DisplayedPrice to receive custom symbol | Create…
FrancoAguzzi Aug 23, 2024
9d082f4
feat: [SC-25297] Refine DisplayedPrice | Create DomainCardPrice
FrancoAguzzi Aug 24, 2024
3518c5f
Update packages/namekit-react/src/components/DisplayedPrice.tsx
FrancoAguzzi Aug 27, 2024
6d43526
Update packages/namekit-react/src/components/DisplayedPrice.tsx
FrancoAguzzi Aug 27, 2024
1bc48fe
feat: optimized props config of DisplayedPrice and CurrencySymbol
FrancoAguzzi Aug 27, 2024
1145913
Merge branch 'francoaguzzi/sc-25297/migrate-displayed-price' of https…
FrancoAguzzi Aug 27, 2024
0dfb5f9
feat: [SC-25297] Optimized DisplayedPrice and DisplayedPriceConversio…
FrancoAguzzi Aug 29, 2024
5d9f8f1
Update packages/namekit-react/src/components/CurrencySymbol/CurrencyS…
FrancoAguzzi Aug 31, 2024
7e1ff72
Update packages/namekit-react/src/components/CurrencySymbol/CurrencyS…
FrancoAguzzi Aug 31, 2024
b4102df
Update packages/namekit-react/src/components/CurrencySymbol/CurrencyS…
FrancoAguzzi Aug 31, 2024
638108e
Update packages/namekit-react/src/components/DisplayedPrice.tsx
FrancoAguzzi Aug 31, 2024
ac9d1a5
feat: [SC-25297] Move CurrencySymbol related components in namekit-react
FrancoAguzzi Sep 3, 2024
96e8914
feat: [SC-25297] Optimize DisplayedPrice const defining in namekit-react
FrancoAguzzi Sep 3, 2024
577f5c3
feat: [SC-25297] Update namekit-react Storybook stories
FrancoAguzzi Sep 3, 2024
3e16064
Merge remote-tracking branch 'origin/main' into francoaguzzi/sc-25297…
FrancoAguzzi Sep 6, 2024
ba90eea
feat: [SC-25297] Update exporting of Price components to reside in cl…
FrancoAguzzi Sep 6, 2024
cbde6b6
feat: [SC-25297] Update namekit-react Price comps. docs.
FrancoAguzzi Sep 6, 2024
af9334e
Update packages/namekit-react/src/components/CurrencySymbol.tsx
FrancoAguzzi Sep 8, 2024
1965f32
Update packages/namekit-react/src/components/CurrencySymbol.tsx
FrancoAguzzi Sep 8, 2024
7db6237
Update packages/namekit-react/src/components/CurrencySymbol.tsx
FrancoAguzzi Sep 10, 2024
12be939
Update .changeset/quick-ads-pretend.md
FrancoAguzzi Sep 10, 2024
d736ba5
Merge remote-tracking branch 'origin/main' into francoaguzzi/sc-25297…
FrancoAguzzi Sep 10, 2024
7514805
feat: [SC-25297] Refine DisplayedConversionPrice Storybook stories
FrancoAguzzi Sep 10, 2024
31ee390
feat: Update `CurrencySymbol` default prop
FrancoAguzzi Sep 10, 2024
e83797b
Update apps/storybook.namekit.io/stories/Namekit/CurrencySymbol.stori…
FrancoAguzzi Sep 10, 2024
f680557
Update packages/namekit-react/src/components/CurrencySymbol.tsx
FrancoAguzzi Sep 10, 2024
2b3e62f
Update packages/namekit-react/src/components/CurrencySymbol.tsx
FrancoAguzzi Sep 10, 2024
b8e2cbe
feat: [SC-25297] Create GasIcon
FrancoAguzzi Sep 10, 2024
5242ef0
feat: [SC-25297] Refactor Price related stories examples
FrancoAguzzi Sep 10, 2024
f9c7e02
feat: [SC-25297] Rename CurrencySymbology and CurrencySymbolSize props
FrancoAguzzi Sep 10, 2024
a3112ba
feat: [SC-25297] Rename namekit-react icons
FrancoAguzzi Sep 10, 2024
32e3d6d
Merge branch 'francoaguzzi/sc-25297/migrate-displayed-price' of https…
FrancoAguzzi Sep 10, 2024
ab8efc5
Update packages/namekit-react/src/components/CurrencySymbol.tsx
FrancoAguzzi Sep 11, 2024
c190533
feat: [SC-25297] Remove need of UsdTextSymbol
FrancoAguzzi Sep 11, 2024
f068154
feat: [SC-25297] Create explicit className for CurrencySymbol setting
FrancoAguzzi Sep 11, 2024
b3631c1
feat: [SC-25297] Add CurrencySymbol Storybook stories
FrancoAguzzi Sep 11, 2024
792b0c3
feat: [SC-25297] Remove prop as per new alignment to its default value
FrancoAguzzi Sep 11, 2024
a401367
Update packages/namekit-react/src/components/CurrencySymbol.tsx
FrancoAguzzi Nov 4, 2024
7f1a998
Update packages/namekit-react/src/components/CurrencySymbol.tsx
FrancoAguzzi Nov 4, 2024
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
2 changes: 1 addition & 1 deletion .changeset/quick-ads-pretend.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
"@namehash/ens-utils": minor
---

Create DisplayedPrice and DisplayedPriceWithSymbol components + new price utilities
Create DisplayedPrice and DisplayedPriceConversion components + new price utilities
1 change: 0 additions & 1 deletion apps/storybook.namekit.io/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@

.colorful-text {
font-weight: 700;
text-decoration: underline;
color: lightgreen;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,35 @@ import {
CurrencySymbol,
CurrencySymbology,
} from "@namehash/namekit-react/client";
import { CurrencySymbolSize } from "@namehash/namekit-react/client";
import { CurrencyIconSize } from "@namehash/namekit-react/client";
import type { Meta, StoryObj } from "@storybook/react";

FrancoAguzzi marked this conversation as resolved.
Show resolved Hide resolved
const meta: Meta<typeof CurrencySymbol> = {
component: CurrencySymbol,
title: "Namekit/CurrencySymbol",
argTypes: {
currency: {
options: [
Currency.Eth,
Currency.Usd,
Currency.Usdc,
Currency.Weth,
Currency.Dai,
],
control: { type: "select" },
options: Object.values(Currency),
control: {
labels: Object.keys(Currency),
type: "select",
},
},
iconSize: {
options: [CurrencySymbolSize.Large, CurrencySymbolSize.Small],
options: Object.values(CurrencyIconSize),
if: { arg: "symbology", eq: CurrencySymbology.Icon },
control: {
type: "select",
labels: {
[CurrencySymbolSize.Large]:
"Large (20px) (only applicable for Icon symbology)",
[CurrencySymbolSize.Small]:
"Small (16px) (only applicable for Icon symbology)",
[CurrencyIconSize.Small]: "Small (16px)",
[CurrencyIconSize.Large]: "Large (20px)",
},
type: "select",
},
},
className: {
if: { arg: "symbology", neq: CurrencySymbology.Icon },
control: {
type: "text",
},
},
describeCurrencyInTooltip: { control: { type: "boolean" } },
Expand All @@ -39,10 +41,9 @@ const meta: Meta<typeof CurrencySymbol> = {
},
},
args: {
FrancoAguzzi marked this conversation as resolved.
Show resolved Hide resolved
currency: Currency.Eth,
iconSize: CurrencySymbolSize.Small,
iconSize: CurrencyIconSize.Small,
describeCurrencyInTooltip: true,
FrancoAguzzi marked this conversation as resolved.
Show resolved Hide resolved
symbology: CurrencySymbology.Symbol,
symbology: CurrencySymbology.TextSymbol,
},
};

Expand All @@ -52,54 +53,38 @@ type Story = StoryObj<typeof CurrencySymbol>;

export const AsAnAcronym: Story = {
args: {
iconSize: CurrencySymbolSize.Small,
currency: Currency.Eth,
symbology: CurrencySymbology.Acronym,
},
};
export const AsASymbol: Story = {
args: {
currency: Currency.Eth,
symbology: CurrencySymbology.Symbol,
},
};
export const AsAnIcon: Story = {
FrancoAguzzi marked this conversation as resolved.
Show resolved Hide resolved
args: {
currency: Currency.Eth,
iconSize: CurrencySymbolSize.Large,
symbology: CurrencySymbology.Icon,
},
};
export const SmallSize: Story = {
args: {
currency: Currency.Eth,
iconSize: CurrencySymbolSize.Small,
symbology: CurrencySymbology.Icon,
},
};
export const WithCustomSymbolColor: Story = {
export const WithCustomIconColor: Story = {
argTypes: {
fill: { control: { type: "color" } },
},
args: {
currency: Currency.Eth,
iconSize: CurrencySymbolSize.Large,
symbology: CurrencySymbology.Icon,
fill: "#007bff",
},
};
export const WithCustomFontSize: Story = {
export const WithCustomFontStyle: Story = {
argTypes: {
className: { control: { type: "text" } },
},
args: {
className: "nk-text-3xl",
currency: Currency.Eth,
className: "nk-text-3xl colorful-text",
},
};
export const NotShowingTooltipDescription: Story = {
FrancoAguzzi marked this conversation as resolved.
Show resolved Hide resolved
args: {
currency: Currency.Eth,
iconSize: CurrencySymbolSize.Large,
describeCurrencyInTooltip: false,
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
CurrencySymbology,
PriceDisplaySize,
CurrencySymbolPosition,
CurrencySymbolSize,
CurrencyIconSize,
} from "@namehash/namekit-react/client";
import type { Meta, StoryObj } from "@storybook/react";
import {
Expand All @@ -16,20 +16,20 @@ import {
} from "@namehash/ens-utils";
import React, { useEffect, useState } from "react";

const getCurrencySymbolSizeBasedOnPriceDisplaySize = (
const getCurrencyIconSizeBasedOnPriceDisplaySize = (
displaySize: PriceDisplaySize | undefined,
) => {
switch (displaySize) {
case PriceDisplaySize.Large:
return CurrencySymbolSize.Large;
return CurrencyIconSize.Large;
case PriceDisplaySize.Medium:
return CurrencySymbolSize.Large;
return CurrencyIconSize.Large;
case PriceDisplaySize.Small:
return CurrencySymbolSize.Small;
return CurrencyIconSize.Small;
case PriceDisplaySize.Micro:
return CurrencySymbolSize.Small;
return CurrencyIconSize.Small;
default:
return CurrencySymbolSize.Large;
return CurrencyIconSize.Large;
}
};

Expand All @@ -56,13 +56,15 @@ const meta: Meta<typeof DisplayedPrice> = {
"Example With USD price",
"Example With USDC price",
"Example With DAI price",
"Example With GAS price",
],
mapping: {
["Example With ETH price"]: numberAsPrice(1, Currency.Eth),
["Example With WETH price"]: numberAsPrice(1, Currency.Weth),
["Example With USD price"]: numberAsPrice(1, Currency.Usd),
["Example With USDC price"]: numberAsPrice(1, Currency.Usdc),
["Example With DAI price"]: numberAsPrice(1, Currency.Dai),
["Example With GAS price"]: numberAsPrice(1, Currency.Gas),
},
},
/**
Expand Down Expand Up @@ -96,44 +98,35 @@ const meta: Meta<typeof DisplayedPrice> = {
},
},
/**
* The possible `displaySize` values for `DisplayedPrice` component.
* The possible `symbolPosition` values for `DisplayedPrice` component.
*/
displaySize: {
options: [
PriceDisplaySize.Large,
PriceDisplaySize.Medium,
PriceDisplaySize.Small,
PriceDisplaySize.Micro,
],
symbolPosition: {
options: Object.keys(CurrencySymbolPosition),
mapping: CurrencySymbolPosition,
control: {
type: "select",
labels: {
[PriceDisplaySize.Large]: "Large (24px)",
[PriceDisplaySize.Medium]: "Medium (20px)",
[PriceDisplaySize.Small]: "Small (14px)",
[PriceDisplaySize.Micro]: "Micro (12px for mobile, 14px for desktop)",
},
},
},
/**
* The possible `symbolPosition` values for `DisplayedPrice` component.
* The possible `displaySize` values for `DisplayedPrice` component.
*/
symbolPosition: {
options: [CurrencySymbolPosition.Left, CurrencySymbolPosition.Right],
displaySize: {
options: Object.keys(PriceDisplaySize),
mapping: PriceDisplaySize,
control: {
type: "select",
labels: {
[CurrencySymbolPosition.Left]: "Left",
[CurrencySymbolPosition.Right]: "Right",
[PriceDisplaySize.Large]: "Large (24px)",
[PriceDisplaySize.Medium]: "Medium (20px)",
[PriceDisplaySize.Small]: "Small (14px)",
[PriceDisplaySize.Micro]: "Micro (12px for mobile, 14px for desktop)",
},
},
},
},
args: {
price: numberAsPrice(1, Currency.Eth),
symbol: undefined,
displaySize: PriceDisplaySize.Medium,
symbolPosition: CurrencySymbolPosition.Left,
displaySize: PriceDisplaySize.Medium,
},
};

Expand All @@ -159,10 +152,12 @@ const exchangeRatesRecord = {
[Currency.Usd]: 1,
[Currency.Dai]: 1,
[Currency.Usdc]: 1,
[Currency.Gas]: 1,
};

export const LargeDisplaySize: Story = {
args: {
price: numberAsPrice(1, Currency.Eth),
displaySize: PriceDisplaySize.Large,
},
render: (args, ctx) => {
Expand Down Expand Up @@ -238,13 +233,13 @@ export const CustomSymbolUsingOurCurrencySymbol: Story = {
},
render: (args) => {
const [currency, setCurrency] = useState<Currency>(args.price.currency);
const [currencySize, setCurrencySize] = useState<CurrencySymbolSize>(
CurrencySymbolSize.Large,
const [currencySize, setCurrencySize] = useState<CurrencyIconSize>(
CurrencyIconSize.Large,
);

useEffect(() => {
setCurrencySize(
getCurrencySymbolSizeBasedOnPriceDisplaySize(args.displaySize),
getCurrencyIconSizeBasedOnPriceDisplaySize(args.displaySize),
);
}, [args.displaySize]);

Expand All @@ -256,20 +251,13 @@ export const CustomSymbolUsingOurCurrencySymbol: Story = {
<DisplayedPrice
{...args}
symbol={
<div
style={{
marginBottom:
currencySize === CurrencySymbolSize.Large ? "0.1rem" : "",
}}
>
<CurrencySymbol
size={currencySize}
currency={currency}
symbology={CurrencySymbology.Icon}
/>
</div>
<CurrencySymbol
size={currencySize}
currency={currency}
symbology={CurrencySymbology.Icon}
/>
}
></DisplayedPrice>
/>
);
},
};
Expand Down Expand Up @@ -303,11 +291,11 @@ export const OverflowDisplayPriceWithCustomCurrencyIcon: Story = {
},
render: (args) => {
const [currency, setCurrency] = useState<Currency>(args.price.currency);
const [currencySize, setCurrencySize] = useState<CurrencySymbolSize>();
const [currencySize, setCurrencySize] = useState<CurrencyIconSize>();

useEffect(() => {
setCurrencySize(
getCurrencySymbolSizeBasedOnPriceDisplaySize(args.displaySize),
getCurrencyIconSizeBasedOnPriceDisplaySize(args.displaySize),
);
}, [args.displaySize]);

Expand All @@ -331,7 +319,7 @@ export const OverflowDisplayPriceWithCustomCurrencyIcon: Story = {
/>
)
}
></DisplayedPrice>
/>
);
},
};
Expand All @@ -342,11 +330,11 @@ export const UnderflowDisplayPriceWithCustomCurrencyIcon: Story = {
},
render: (args) => {
const [currency, setCurrency] = useState<Currency>(args.price.currency);
const [currencySize, setCurrencySize] = useState<CurrencySymbolSize>();
const [currencySize, setCurrencySize] = useState<CurrencyIconSize>();

useEffect(() => {
setCurrencySize(
getCurrencySymbolSizeBasedOnPriceDisplaySize(args.displaySize),
getCurrencyIconSizeBasedOnPriceDisplaySize(args.displaySize),
);
}, [args.displaySize]);

Expand All @@ -364,13 +352,13 @@ export const UnderflowDisplayPriceWithCustomCurrencyIcon: Story = {
symbol={
args.symbol || (
<CurrencySymbol
size={currencySize}
currency={currency}
iconSize={currencySize}
symbology={CurrencySymbology.Icon}
/>
)
}
></DisplayedPrice>
/>
);
},
};
Loading
Loading