Skip to content

Commit

Permalink
Fix TS typings (and tests)
Browse files Browse the repository at this point in the history
  • Loading branch information
Vadorequest committed Jun 2, 2020
1 parent 2119b06 commit 1e90bfc
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/components/assets/GraphCMSAsset.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ const GraphCMSAsset = (props: Props): JSX.Element => {
key={id}
id={id}
src={resolvedAssetProps.url}
title={resolvedAssetProps.title}
alt={resolvedAssetProps.alt || resolvedAssetProps.title || resolvedAssetProps.url}
title={resolvedAssetProps.filename}
alt={resolvedAssetProps.filename || resolvedAssetProps.url}
className={classnames(`asset-${id}`, className, resolvedAssetProps.classes)}
style={deepmerge(style || {}, resolvedAssetProps.style || {})}
/>
Expand Down
10 changes: 5 additions & 5 deletions src/components/assets/Logo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ const Logo = (props: Props): JSX.Element => {
}

const sizes = generateSizes({
baseWidth: parseFloat(resolvedLogoProps.width as string),
baseHeight: parseFloat(resolvedLogoProps.height as string),
baseWidth: resolvedLogoProps.thumbnails.small.width,
baseHeight: resolvedLogoProps.thumbnails.small.height,
sizesMultipliers,
});

Expand All @@ -89,9 +89,9 @@ const Logo = (props: Props): JSX.Element => {
key={id}
id={id}
src={resolvedLogoProps.url}
title={resolvedLogoProps.title}
alt={resolvedLogoProps.alt || resolvedLogoProps.title || resolvedLogoProps.url}
className={classnames(`logo-${id}`, className, resolvedLogoProps.classes)}
title={resolvedLogoProps.filename}
alt={resolvedLogoProps.filename || resolvedLogoProps.url}
className={classnames(`logo-${id}`, className)}
style={deepmerge(style || {}, resolvedLogoProps.style || {})}
onClick={onClick}
/>
Expand Down
4 changes: 2 additions & 2 deletions src/types/data/AirtableSystemFields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
* Those fields are available on any Airtable record.
*/
export declare type AirtableSystemFields = {
id: string;
createdTime: string;
id?: string;
createdTime?: string;
}
14 changes: 11 additions & 3 deletions src/types/data/Asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,20 @@ export type AssetThumbnail = {
* All fields are managed internally by Airtable and we have no control over them (they're not columns)
*/
export declare type Asset = {
url: string;
filename: string;
url?: string;
filename?: string;
size?: number;
type?: string;
thumbnails?: {
small?: AssetThumbnail;
large?: AssetThumbnail;
}
};

// NRN own fields, dynamically set when manipulating assets
classes?: string;
defaultTransformations?: object;
linkTarget?: string;
linkUrl?: string;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
style?: string | object | any;
} & AirtableSystemFields;

0 comments on commit 1e90bfc

Please sign in to comment.