Skip to content

Commit 9808d9e

Browse files
committed
almost working
1 parent 502b900 commit 9808d9e

File tree

33 files changed

+1727
-133
lines changed

33 files changed

+1727
-133
lines changed

.eslintignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,6 @@ packages/create-docusaurus/templates/facebook
2222

2323
website/_dogfooding/_swizzle_theme_tests
2424
website/_dogfooding/_asset-tests/badSyntax.js
25+
26+
27+
packages/docusaurus-plugin-ideal-image/src/theme/IdealImageLegacy

packages/docusaurus-plugin-ideal-image/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
"@docusaurus/theme-translations": "3.7.0",
2727
"@docusaurus/types": "3.7.0",
2828
"@docusaurus/utils-validation": "3.7.0",
29-
"@slorber/react-ideal-image": "^0.0.14",
3029
"react-waypoint": "^10.3.0",
3130
"sharp": "^0.32.3",
3231
"tslib": "^2.6.0",

packages/docusaurus-plugin-ideal-image/src/deps.d.ts

Lines changed: 0 additions & 124 deletions
This file was deleted.

packages/docusaurus-plugin-ideal-image/src/plugin-ideal-image.d.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,17 @@ declare module '@docusaurus/plugin-ideal-image' {
5151
export type Options = Partial<PluginOptions>;
5252
}
5353

54+
declare module '@theme/IdealImageLegacy' {
55+
import type {ReactNode} from 'react';
56+
import type {ImageProps} from './theme/IdealImageLegacy/types';
57+
58+
export type {IconKey, State} from './theme/IdealImageLegacy/types';
59+
60+
export interface Props extends ImageProps {}
61+
62+
export default function IdealImageLegacy(props: ImageProps): ReactNode;
63+
}
64+
5465
declare module '@theme/IdealImage' {
5566
import type {ComponentProps, ReactNode} from 'react';
5667

packages/docusaurus-plugin-ideal-image/src/theme/IdealImage/index.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
*/
77

88
import React, {type ReactNode} from 'react';
9+
import {translate} from '@docusaurus/Translate';
910
import ReactIdealImage, {
1011
type IconKey,
1112
type State,
12-
} from '@slorber/react-ideal-image';
13-
import {translate} from '@docusaurus/Translate';
13+
} from '@theme/IdealImageLegacy';
1414

1515
import type {Props} from '@theme/IdealImage';
1616

@@ -93,7 +93,6 @@ export default function IdealImage(props: Props): ReactNode {
9393

9494
return (
9595
<ReactIdealImage
96-
{...propsRest}
9796
height={img.src.height ?? 100}
9897
width={img.src.width ?? 100}
9998
placeholder={{lqip: img.preSrc}}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
The MIT License (MIT)
2+
Copyright (c) 2017 stereobooster
3+
4+
Permission is hereby granted, free of charge, to any person obtaining a copy
5+
of this software and associated documentation files (the "Software"), to deal
6+
in the Software without restriction, including without limitation the rights
7+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
copies of the Software, and to permit persons to whom the Software is
9+
furnished to do so, subject to the following conditions:
10+
11+
The above copyright notice and this permission notice shall be included in all
12+
copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+
SOFTWARE.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Legacy React IdealImage lib
2+
3+
This is legacy code from an npm package we forked, then internalized
4+
5+
See also:
6+
7+
- https://github.com/slorber/docusaurus-react-ideal-image
8+
- https://github.com/endiliey/react-ideal-image
9+
- https://github.com/stereobooster/react-ideal-image
10+
11+
---
12+
13+
TODO: we need to clean it up, remove what we don't need, and maintain it up to date
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`Download icon Should render a snapshot that is good 1`] = `
4+
<svg
5+
height={24}
6+
viewBox="0 0 24 24"
7+
width={24}
8+
xmlns="http://www.w3.org/2000/svg"
9+
>
10+
<path
11+
d="M0 0h24v24H0z"
12+
fill="none"
13+
/>
14+
<path
15+
d="M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96zM17 13l-5 5-5-5h3V9h4v4h3z"
16+
fill="#000"
17+
/>
18+
</svg>
19+
`;
20+
21+
exports[`Loading icon Should render a snapshot that is good 1`] = `
22+
<svg
23+
height={24}
24+
viewBox="0 0 24 24"
25+
width={24}
26+
xmlns="http://www.w3.org/2000/svg"
27+
>
28+
<path
29+
d="M0 0h24v24H0z"
30+
fill="none"
31+
/>
32+
<path
33+
d="M6,2V8H6V8L10,12L6,16V16H6V22H18V16H18V16L14,12L18,8V8H18V2H6M16,16.5V20H8V16.5L12,12.5L16,16.5M12,11.5L8,7.5V4H16V7.5L12,11.5Z"
34+
fill="#000"
35+
/>
36+
</svg>
37+
`;
38+
39+
exports[`Offline icon Should render a snapshot that is good 1`] = `
40+
<svg
41+
height={24}
42+
viewBox="0 0 24 24"
43+
width={24}
44+
xmlns="http://www.w3.org/2000/svg"
45+
>
46+
<path
47+
d="M0 0h24v24H0z"
48+
fill="none"
49+
/>
50+
<path
51+
d="M19.35 10.04C18.67 6.59 15.64 4 12 4c-1.48 0-2.85.43-4.01 1.17l1.46 1.46C10.21 6.23 11.08 6 12 6c3.04 0 5.5 2.46 5.5 5.5v.5H19c1.66 0 3 1.34 3 3 0 1.13-.64 2.11-1.56 2.62l1.45 1.45C23.16 18.16 24 16.68 24 15c0-2.64-2.05-4.78-4.65-4.96zM3 5.27l2.75 2.74C2.56 8.15 0 10.77 0 14c0 3.31 2.69 6 6 6h11.73l2 2L21 20.73 4.27 4 3 5.27zM7.73 10l8 8H6c-2.21 0-4-1.79-4-4s1.79-4 4-4h1.73z"
52+
fill="#000"
53+
/>
54+
</svg>
55+
`;
56+
57+
exports[`Warning icon Should render a snapshot that is good 1`] = `
58+
<svg
59+
height={24}
60+
viewBox="0 0 24 24"
61+
width={24}
62+
xmlns="http://www.w3.org/2000/svg"
63+
>
64+
<path
65+
d="M0 0h24v24H0z"
66+
fill="none"
67+
/>
68+
<path
69+
d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z"
70+
fill="#000"
71+
/>
72+
</svg>
73+
`;
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import compose from '../components/composeStyle';
2+
3+
describe('composeStyle', () => {
4+
it('Should combine object classes into one className string', () => {
5+
const theme = {
6+
base: 'base',
7+
element: 'base__element',
8+
};
9+
const result = compose(theme.base, theme.element);
10+
expect(result.className).toEqual(`${theme.base} ${theme.element}`);
11+
});
12+
13+
it('Should return a styles object unmodified', () => {
14+
const style = {
15+
color: 'blue',
16+
margin: '1em 0',
17+
};
18+
const result = compose(style);
19+
const expected = style;
20+
expect(result.style).toEqual(expected);
21+
});
22+
23+
it('Should throw an error if given a parameter not an object or string', () => {
24+
const number = 1;
25+
try {
26+
compose(number);
27+
expect(true).toBe(false);
28+
} catch (e) {
29+
expect(e.message).toBe(`Unexpected value ${number}`);
30+
}
31+
});
32+
});

0 commit comments

Comments
 (0)