diff --git a/packages/elements-core/src/components/Docs/HttpService/AdditionalInfo.stories.ts b/packages/elements-core/src/components/Docs/HttpService/AdditionalInfo.stories.ts new file mode 100644 index 000000000..4cf7568ed --- /dev/null +++ b/packages/elements-core/src/components/Docs/HttpService/AdditionalInfo.stories.ts @@ -0,0 +1,45 @@ +import { Meta, StoryObj } from '@storybook/react'; + +import { AdditionalInfo } from './AdditionalInfo'; + +const meta: Meta = { + title: `Internal/Docs/AdditionalInfo`, + component: AdditionalInfo, +}; + +export default meta; +type Story = StoryObj; + +export const LicenseNameAndURL: Story = { + name: 'License Name with URL', + args: { + id: 'id', + license: { + name: 'MIT License', + url: 'https://mit.edu/license.html', + }, + }, +}; + +export const LicenseNameAndIdentifier: Story = { + name: 'License Name and Identifier', + args: { + id: 'id', + license: { + name: 'MIT License', + identifier: `MIT`, + }, + }, +}; + +export const LicenseIdentifierAndNameAndUrl: Story = { + name: 'License Identifier, Name and URL', + args: { + id: 'id', + license: { + name: 'MIT License', + identifier: 'MIT', + url: 'https://mit.edu/license.html', + }, + }, +}; diff --git a/packages/elements-core/src/components/Docs/HttpService/AdditionalInfo.tsx b/packages/elements-core/src/components/Docs/HttpService/AdditionalInfo.tsx index bcc95a0a4..89e13eb9d 100644 --- a/packages/elements-core/src/components/Docs/HttpService/AdditionalInfo.tsx +++ b/packages/elements-core/src/components/Docs/HttpService/AdditionalInfo.tsx @@ -24,8 +24,14 @@ export const AdditionalInfo: React.FC = ({ id, termsOfServi : ''; //use spdx to look up url for license identifier if available - const licenseUrl = license?.url || `https://spdx.org/licenses/${license?.identifier}.html`; - const licenseLink = license?.name && licenseUrl ? `[${license.name} License](${licenseUrl})` : ''; + const licenseUrl = + license?.url || license?.identifier ? `https://spdx.org/licenses/${license?.identifier}.html` : undefined; + const licenseLink = + license?.name && licenseUrl + ? `[${license.name}](${licenseUrl})` + : license?.identifier && licenseUrl + ? `[${license?.identifier}](${licenseUrl})` + : undefined; const tosLink = termsOfService ? `[Terms of Service](${termsOfService})` : ''; return contactLink || licenseLink || tosLink ? (