-
Notifications
You must be signed in to change notification settings - Fork 710
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Andres Martinez Gotor
authored
Sep 24, 2020
1 parent
78a8c7f
commit 747a1a1
Showing
14 changed files
with
102 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
.app-secrets-content { | ||
margin-top: 1.2rem; | ||
margin-right: 1.2rem; | ||
} | ||
|
||
.app-secrets-section { | ||
max-height: 10rem; | ||
overflow-y: auto; | ||
} |
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
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,24 @@ | ||
import * as React from "react"; | ||
import { act } from "react-dom/test-utils"; | ||
import { defaultStore, mountWrapper } from "shared/specs/mountWrapper"; | ||
import Icon from "./Icon"; | ||
|
||
it("should render an icon", () => { | ||
const wrapper = mountWrapper(defaultStore, <Icon icon="foo" />); | ||
expect(wrapper.find("img").prop("src")).toBe("foo"); | ||
}); | ||
|
||
it("should use the default icon if not given", () => { | ||
const wrapper = mountWrapper(defaultStore, <Icon />); | ||
expect(wrapper.find("img").prop("src")).toBe("placeholder.png"); | ||
}); | ||
|
||
it("should fallback to the placeholder if an error happens", () => { | ||
const wrapper = mountWrapper(defaultStore, <Icon icon="foo" />); | ||
expect(wrapper.find("img").prop("src")).toBe("foo"); | ||
act(() => { | ||
wrapper.find("img").simulate("error", {}); | ||
}); | ||
wrapper.update(); | ||
expect(wrapper.find("img").prop("src")).toBe("placeholder.png"); | ||
}); |
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,26 @@ | ||
import React, { useEffect, useState } from "react"; | ||
|
||
import placeholder from "../../placeholder.png"; | ||
|
||
export interface IIconProps { | ||
icon?: any; | ||
} | ||
|
||
function Icon({ icon }: IIconProps) { | ||
const [srcIcon, setSrcIcon] = useState(placeholder); | ||
const [iconErrored, setIconErrored] = useState(false); | ||
useEffect(() => { | ||
if (srcIcon !== icon && icon && !iconErrored) { | ||
setSrcIcon(icon); | ||
} | ||
}, [srcIcon, icon, iconErrored]); | ||
|
||
const onError = () => { | ||
setIconErrored(true); | ||
setSrcIcon(placeholder); | ||
}; | ||
|
||
return <img src={srcIcon} alt="icon" onError={onError} />; | ||
} | ||
|
||
export default Icon; |
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
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