Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/npm_and_yarn/react-github-btn-1.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-smartbear committed Aug 16, 2024
2 parents e14f4c3 + e78e756 commit 1375545
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { Meta, StoryObj } from '@storybook/react';

import { AdditionalInfo } from './AdditionalInfo';

const meta: Meta<typeof AdditionalInfo> = {
title: `Internal/Docs/AdditionalInfo`,
component: AdditionalInfo,
};

export default meta;
type Story = StoryObj<typeof AdditionalInfo>;

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',
},
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,14 @@ export const AdditionalInfo: React.FC<AdditionalInfoProps> = ({ 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 ? (
Expand Down

0 comments on commit 1375545

Please sign in to comment.