-
-
Notifications
You must be signed in to change notification settings - Fork 421
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support custom renderImage functions for Card
Since in some cases, for example next.js apps, one needs to use a specific and optimized `Image` component, the `Card` component now accepts a `renderImage` property to render your own component. If `renderImage` is set, `imgSrc` and `imgAlt` are ignored. TypeScript will error if the user attempts to set them at the same time. fix #706
- Loading branch information
Showing
6 changed files
with
132 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { describe, expect, it } from 'vitest'; | ||
import { omit } from './omit'; | ||
|
||
describe('omit', () => { | ||
it('should omit keys from object', () => { | ||
expect(omit(['a', 'b'])({ a: 'a', b: 'b', c: 'c' })).toEqual({ c: 'c' }); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
export const omit = | ||
<T extends object, K extends string>(keys: readonly K[]) => | ||
(obj: T): Omit<T, K> => { | ||
const result = {} as Omit<T, K>; | ||
Object.keys(obj).forEach((key) => { | ||
//@ts-expect-error - Somehow TS does not like this. | ||
if (keys.includes(key)) { | ||
return; | ||
} | ||
//@ts-expect-error - Somehow TS does not like this. | ||
result[key] = obj[key]; | ||
}); | ||
return result; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters