Skip to content

Commit

Permalink
Merge pull request #122 from 90lucasgabriel/feature/WJ-121
Browse files Browse the repository at this point in the history
WJ-121 - Fix cross-browsers errors
  • Loading branch information
90lucasgabriel committed Nov 17, 2020
2 parents 8f2ac21 + 0332556 commit 175f4ea
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/components/Button/index.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe('Button Component', () => {

// Assert
expect(containerElement).toHaveStyle(`border-color: ${Color.Secondary}`);
expect(containerElement).toHaveStyle('background: transparent');
expect(containerElement).toHaveStyle(`background: ${Color.Transparent}`);
});

it('should render an icon button', async () => {
Expand All @@ -61,7 +61,7 @@ describe('Button Component', () => {

// Assert
expect(containerElement).toHaveStyle('border-radius: 50%');
expect(containerElement).toHaveStyle('background: transparent');
expect(containerElement).toHaveStyle(`background: ${Color.Transparent}`);
expect(containerElement).toHaveStyle('width: auto');
expect(containerElement).toHaveStyle('height: auto');
});
Expand Down
6 changes: 3 additions & 3 deletions src/components/Button/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const Container = styled.button<ButtonProps>`
css`
border: 1px solid ${getBackground(props.theme, props.color, Color.Fill)};
color: ${getBackground(props.theme, props.color, Color.Fill)};
background: transparent;
background: ${Color.Transparent};
&:hover {
background-color: ${`${getBackground(
Expand All @@ -55,7 +55,7 @@ export const Container = styled.button<ButtonProps>`
css`
border: 0;
color: ${getBackground(props.theme, props.color, Color.Fill)};
background: transparent;
background: ${Color.Transparent};
&:hover {
background-color: ${`${getBackground(
Expand All @@ -75,7 +75,7 @@ export const Container = styled.button<ButtonProps>`
height: auto;
padding: ${Size.Small};
border-radius: 50%;
background: transparent;
background: ${Color.Transparent};
&:hover {
background: rgba(0, 0, 0, 0.1);
Expand Down
2 changes: 1 addition & 1 deletion src/components/Input/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const Container = styled.div<ContainerProps>`
`}
input {
background: transparent;
background: ${Color.Transparent};
flex: 1;
border: 0;
font-size: ${Size.Default};
Expand Down
3 changes: 3 additions & 0 deletions src/components/Modal/hooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const ModalProvider: React.FC = ({ children }) => {
({ value, callback, props }: ModalContent) => {
setData(value);
setPropsData(props || ({} as StyleProps));
document.body.style.overflow = 'hidden';

if (callback) {
setCallbackFunction(() => callback);
Expand All @@ -36,13 +37,15 @@ const ModalProvider: React.FC = ({ children }) => {
setIsCallback(true);
setData(null as any);
setPropsData({} as StyleProps);
document.body.style.overflow = 'auto';
}, []);

// Dismiss modal without callback
const dismissModal = useCallback(() => {
setIsCallback(false);
setData(null as any);
setPropsData({} as StyleProps);
document.body.style.overflow = 'auto';
}, []);

// Run callback when close modal and reset state
Expand Down
2 changes: 1 addition & 1 deletion src/containers/EntityImage/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export const IconButton = styled.button`
position: absolute;
right: ${Size.Smallest};
top: ${Size.Smallest};
background: transparent;
background: ${Color.Transparent};
border: none;
svg {
Expand Down
10 changes: 6 additions & 4 deletions src/containers/EntityImageList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,20 @@ const EntityImageList: React.FC<Props> = ({
// Prev navigate button
const handlePrevious = useCallback(() => {
const itemsContainerDOM = itemsContainer.current as HTMLDivElement;
itemsContainerDOM.scrollBy(-1, 0);
const itemWidth = itemsContainerDOM?.scrollWidth / data.length;
itemsContainerDOM.scrollBy(-itemWidth, 0);

checkButtons(false);
}, [itemsContainer, checkButtons]);
}, [itemsContainer, data.length, checkButtons]);

// Next navigate button
const handleNext = useCallback(() => {
const itemsContainerDOM = itemsContainer.current as HTMLDivElement;
itemsContainerDOM.scrollBy(1, 0);
const itemWidth = itemsContainerDOM?.scrollWidth / data.length;
itemsContainerDOM.scrollBy(itemWidth, 0);

checkButtons(true);
}, [itemsContainer, checkButtons]);
}, [itemsContainer, data.length, checkButtons]);

return (
<AnimatePresence>
Expand Down
1 change: 1 addition & 0 deletions src/containers/EntityImageList/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export const ListContainer = styled.div`
-webkit-overflow-scrolling: touch;
scroll-behavior: smooth;
scrollbar-width: none;
&::-webkit-scrollbar {
display: none;
}
Expand Down
4 changes: 2 additions & 2 deletions src/containers/EntitySummaryList/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import styled from 'styled-components';
import { Color, Size } from 'shared/enums';

export const Container = styled.div`
display: flex;
flex-direction: column;
/* display: flex;
flex-direction: column; */
width: 100%;
`;

Expand Down
1 change: 0 additions & 1 deletion src/containers/SearchModal/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export const Container = styled.div`
width: min(1280px, calc(100vw - ${Size.Medium} * 2));
min-height: 100px;
max-height: calc(min(700px, 100%) - 100px - ${Size.Medium});
`;

export const ResultsContainer = styled.div`
Expand Down
2 changes: 1 addition & 1 deletion src/shared/enums/Color.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ enum Color {
Placeholder = '#ccc',
Error = '#c53030',
Empty = '#0f0f0f',
Transparent = 'transparent',
Transparent = 'rgba(255,255,255,0.001)',
}

export default Color;
4 changes: 3 additions & 1 deletion src/shared/helpers/colors/getBackground.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ const getBackground = (
color?: string,
defaultColor?: Color | string,
): Color | string => {
return color || getBackgroundByTheme(theme) || defaultColor || 'transparent';
return (
color || getBackgroundByTheme(theme) || defaultColor || Color.Transparent
);
};

export default getBackground;

0 comments on commit 175f4ea

Please sign in to comment.