diff --git a/web/apps/admin/package.json b/web/apps/admin/package.json index f90c4e5272..006dd736c1 100644 --- a/web/apps/admin/package.json +++ b/web/apps/admin/package.json @@ -20,7 +20,7 @@ "@radix-ui/react-icons": "^1.3.0", "@raystack/apsara": "^1.1.0", "@raystack/frontier": "workspace:^", - "@raystack/proton": "0.1.0-859ba765e6cfd44736ddcf42664b742fe7fd916e", + "@raystack/proton": "0.1.0-94668c362cad03165629c14c7b1abf753e885496", "@stitches/react": "^1.2.8", "@tanstack/react-query": "^5.90.2", "@tanstack/react-query-devtools": "^5.90.2", diff --git a/web/pnpm-lock.yaml b/web/pnpm-lock.yaml index 2ee7dc093c..ae3192bcbe 100644 --- a/web/pnpm-lock.yaml +++ b/web/pnpm-lock.yaml @@ -61,8 +61,8 @@ importers: specifier: workspace:^ version: link:../../sdk '@raystack/proton': - specifier: 0.1.0-859ba765e6cfd44736ddcf42664b742fe7fd916e - version: 0.1.0-859ba765e6cfd44736ddcf42664b742fe7fd916e(@tanstack/query-core@5.90.20)(@tanstack/react-query@5.90.21(react@19.2.4))(react-dom@19.2.4(react@19.2.4))(react@19.2.4) + specifier: 0.1.0-94668c362cad03165629c14c7b1abf753e885496 + version: 0.1.0-94668c362cad03165629c14c7b1abf753e885496(@tanstack/query-core@5.90.20)(@tanstack/react-query@5.90.21(react@19.2.4))(react-dom@19.2.4(react@19.2.4))(react@19.2.4) '@stitches/react': specifier: ^1.2.8 version: 1.2.8(react@19.2.4) @@ -1587,14 +1587,6 @@ packages: '@types/react': optional: true - '@raystack/proton@0.1.0-859ba765e6cfd44736ddcf42664b742fe7fd916e': - resolution: {integrity: sha512-82QvGoJjcp5zGt/QIkdSJEn2iX8vn/g2H4jm8O3QH3YIZuZp0bXFXo+ddD5S49tSUtWiegi7qWJargHgBceLPg==} - peerDependencies: - '@tanstack/react-query': ^5.0.0 - peerDependenciesMeta: - '@tanstack/react-query': - optional: true - '@raystack/proton@0.1.0-94668c362cad03165629c14c7b1abf753e885496': resolution: {integrity: sha512-C1dqPzOnF0Pb1Pyx5kKUPFtclNFravCNVM1kpfvgk2dUgkNlYd7kDCQpma0LOhs/gkddt2usu+U4qRjhykgyQQ==} peerDependencies: @@ -8076,20 +8068,6 @@ snapshots: - '@date-fns/tz' - date-fns - '@raystack/proton@0.1.0-859ba765e6cfd44736ddcf42664b742fe7fd916e(@tanstack/query-core@5.90.20)(@tanstack/react-query@5.90.21(react@19.2.4))(react-dom@19.2.4(react@19.2.4))(react@19.2.4)': - dependencies: - '@bufbuild/protobuf': 2.11.0 - '@connectrpc/connect': 2.1.1(@bufbuild/protobuf@2.11.0) - '@connectrpc/connect-query': 2.1.1(@bufbuild/protobuf@2.11.0)(@connectrpc/connect@2.1.1(@bufbuild/protobuf@2.11.0))(@tanstack/query-core@5.90.20)(@tanstack/react-query@5.90.21(react@19.2.4))(react-dom@19.2.4(react@19.2.4))(react@19.2.4) - '@protobuf-ts/runtime': 2.11.1 - '@protobuf-ts/runtime-rpc': 2.11.1 - optionalDependencies: - '@tanstack/react-query': 5.90.21(react@19.2.4) - transitivePeerDependencies: - - '@tanstack/query-core' - - react - - react-dom - '@raystack/proton@0.1.0-94668c362cad03165629c14c7b1abf753e885496(@tanstack/query-core@5.90.20)(@tanstack/react-query@5.90.21(react@19.2.4))(react-dom@19.2.4(react@19.2.4))(react@19.2.4)': dependencies: '@bufbuild/protobuf': 2.11.0 diff --git a/web/sdk/client/views/plans/components/feature-info.tsx b/web/sdk/client/views/plans/components/feature-info.tsx new file mode 100644 index 0000000000..f84514d276 --- /dev/null +++ b/web/sdk/client/views/plans/components/feature-info.tsx @@ -0,0 +1,62 @@ +'use client'; + +import { IconButton, Link, Popover } from '@raystack/apsara'; +import { InfoCircledIcon } from '@radix-ui/react-icons'; +import styles from './feature-table.module.css'; + +/* + * Matches [label](url) for http, https and mailto urls only. + * - Label needs a non-space character, so [ ](url) stays text. + * - Label can't hold brackets, so [[a](url) links only "a". + * - http(s) needs // and a host, so https:x and https://#a stay text. + * - Url may hold balanced parentheses one level deep, e.g. .../Foo_(bar). + */ +const LINK_PATTERN = + /\[(\s*[^[\]\s][^[\]]*)\]\(((?:https?:\/\/(?=[^\s()/?#])|mailto:)(?:[^()\s]|\([^()\s]*\))+)\)/; + +interface FeatureInfoProps { + title: string; + info: string; +} + +export function FeatureInfo({ title, info }: FeatureInfoProps) { + return ( + + + } + > + + + } + > + {/* split() returns [text, label, url, text, label, url, ..., text] */} + {info.split(LINK_PATTERN).map((part, i, parts) => { + if (i % 3 === 0) return part; + if (i % 3 === 2) return null; + const url = parts[i + 1]; + return ( + + {part} + + ); + })} + + + ); +} diff --git a/web/sdk/client/views/plans/components/feature-table.module.css b/web/sdk/client/views/plans/components/feature-table.module.css index a394fc182b..5ed0e0c72a 100644 --- a/web/sdk/client/views/plans/components/feature-table.module.css +++ b/web/sdk/client/views/plans/components/feature-table.module.css @@ -43,3 +43,13 @@ height: 16px; flex-shrink: 0; } + +/* + * Figma: 16px icon in fg/Subtle. + * - IconButton adds 2px padding and a darker colour. + * - .cell raises specificity so this wins over Apsara's class in any load order. + */ +.cell .infoTrigger { + padding: 0; + color: var(--rs-color-foreground-base-tertiary); +} diff --git a/web/sdk/client/views/plans/components/feature-table.tsx b/web/sdk/client/views/plans/components/feature-table.tsx index 71d7e7563d..ea72adf5fe 100644 --- a/web/sdk/client/views/plans/components/feature-table.tsx +++ b/web/sdk/client/views/plans/components/feature-table.tsx @@ -1,16 +1,35 @@ 'use client'; import { Flex, Image, Skeleton, Text } from '@raystack/apsara'; -import { InfoCircledIcon } from '@radix-ui/react-icons'; import { get } from 'lodash'; +import { Feature } from '@raystack/proton/frontier'; import { IntervalKeys, IntervalPricingWithPlan, PlanIntervalPricing } from '~/src/types'; import checkCircle from '~/client/assets/check-circle.svg'; +import { FeatureInfo } from '~/client/views/plans/components/feature-info'; import styles from './feature-table.module.css'; +/* + * Normalises a feature cell value to a string. + * - Falsy values (missing, '', false, 0) become '-'. + * - Plain values go through String(), so lowercasing a number or boolean doesn't throw. + */ +function normalizeFeatureValue(value: unknown): string { + return value ? String(value) : '-'; +} + +/* + * Reads the feature's info text. + * - Only a non-blank string shows the info icon. + */ +function getFeatureInfo(feature: Feature): string { + const info = feature.metadata?.info; + return typeof info === 'string' ? info.trim() : ''; +} + interface FeatureValueCellProps { feature: string; plan?: IntervalPricingWithPlan; @@ -21,8 +40,8 @@ function FeatureValueCell({ feature, plan }: FeatureValueCellProps) { const productMetaDataFeatureValues = plan?.productNames .map(name => get(planFeature.metadata, name)) .filter(value => value !== undefined); - const value = productMetaDataFeatureValues?.[0] || '-'; - const isAvailable = value?.toLowerCase() === 'true'; + const value = normalizeFeatureValue(productMetaDataFeatureValues?.[0]); + const isAvailable = value.toLowerCase() === 'true'; return ( @@ -42,7 +61,7 @@ function FeatureValueCell({ feature, plan }: FeatureValueCellProps) { } export interface FeatureTableProps { - features: string[]; + features: Feature[]; plans: PlanIntervalPricing[]; selectedIntervals: Record; isLoading?: boolean; @@ -91,13 +110,17 @@ export function FeatureTable({ return ( - {features.map(feature => ( - - - {feature} - - - ))} + {features.map(feature => { + const info = getFeatureInfo(feature); + return ( + + + {feature.title} + + {info && } + + ); + })} {plans.map(plan => { @@ -111,8 +134,8 @@ export function FeatureTable({ > {features.map(feature => ( ))} diff --git a/web/sdk/client/views/plans/plans-view.tsx b/web/sdk/client/views/plans/plans-view.tsx index a9a8a694eb..89b8b353ea 100644 --- a/web/sdk/client/views/plans/plans-view.tsx +++ b/web/sdk/client/views/plans/plans-view.tsx @@ -82,18 +82,17 @@ export function PlansView() { const sortedFeatures = useMemo(() => { const featureTitleMap = features.reduce( (acc, f) => { - const weightage = - (f.metadata as Record)?.weightage || totalFeatures; - acc[f.title || ''] = weightage; + acc[f.title || ''] = f; return acc; }, - {} as Record + {} as Record ); + const weightage = (f: Feature) => + (f.metadata as Record)?.weightage || totalFeatures; - return Object.entries(featureTitleMap) - .sort((f1, f2) => f1[1] - f2[1]) - .map(f => f[0]) - .filter(Boolean); + return Object.values(featureTitleMap) + .sort((f1, f2) => weightage(f1) - weightage(f2)) + .filter(f => Boolean(f.title)); }, [features, totalFeatures]); const [intervalOverrides, setIntervalOverrides] = useState<