Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(arcgis): auth UI #326

Merged
merged 10 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions public/icons/download-2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions public/icons/import.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions public/icons/logout.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion public/icons/plus.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions public/images/esri.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import {
color_brand_secondary_dark,
color_accent_primary,
color_accent_tertiary,
color_brand_tertiary,
dim_brand_tertinary
} from "./constants/colors";
import * as Pages from "./pages";
import { AppThemes, ComparisonMode, Theme } from "./types";
Expand Down Expand Up @@ -75,6 +77,16 @@ const THEMES: AppThemes = {
validateTileOk: color_brand_secondary_dark,
validateTileWarning: color_accent_tertiary,
filtrationImage: color_brand_quaternary,

actionIconButtonDisabledColor: color_canvas_primary,
actionIconButtonDisabledBG: dim_canvas_primary,
actionIconButtonTextDisabledColor: dim_canvas_primary,
actionIconButtonTextDisabledColorHover: dim_brand_tertinary,

logoutButtonTextColor: dim_canvas_primary,
logoutButtonIconColorHover: dim_brand_tertinary,

esriImageColor: color_canvas_secondary_inverted,
},
name: Theme.Dark,
},
Expand Down Expand Up @@ -106,6 +118,16 @@ const THEMES: AppThemes = {
validateTileOk: color_brand_secondary,
validateTileWarning: color_accent_primary,
filtrationImage: color_canvas_secondary,

actionIconButtonDisabledColor: color_canvas_secondary,
actionIconButtonDisabledBG: `${color_brand_tertiary}66`,
actionIconButtonTextDisabledColor: `${color_brand_tertiary}66`,
actionIconButtonTextDisabledColorHover: color_brand_tertiary,

logoutButtonTextColor: color_brand_quaternary,
logoutButtonIconColorHover: color_brand_tertiary,

esriImageColor: `${color_brand_tertiary}66`,
},
name: Theme.Light,
},
Expand Down Expand Up @@ -160,3 +182,4 @@ export const App = () => {
</>
);
};

belom88 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@ import { screen } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { ButtonSize } from "../../types";
import { renderWithTheme } from "../../utils/testing-utils/render-with-theme";
import { PlusButton } from "./plus-button";
import PlusIcon from "../../../public/icons/plus.svg";
import { ActionIconButton } from "../action-icon-button/action-icon-button";

const onClickMock = jest.fn();

const callRender = (renderFunc, props = {}) => {
return renderFunc(
<PlusButton
buttonSize={ButtonSize.Small}
<ActionIconButton
Icon={PlusIcon}
style='disabled'
size={ButtonSize.Small}
onClick={onClickMock}
{...props} />
);
Expand All @@ -20,23 +23,21 @@ describe("Plus Button", () => {
const { container } = callRender(renderWithTheme, { children: 'Test Button' });
expect(container).toBeInTheDocument();
const button = screen.getByText('Test Button');
const buttonHeight = getComputedStyle(button.previousSibling as Element).getPropertyValue(
"height"
);
const buttonHeight = getComputedStyle(button.previousSibling as Element).getPropertyValue("height");
expect(buttonHeight).toEqual('24px');

userEvent.click(button);
expect(onClickMock).toHaveBeenCalled();
});

it("Should render Big Plus button", () => {
const { container } = callRender(renderWithTheme, { children: 'Test Button', buttonSize: ButtonSize.Big });
const { container } = callRender(renderWithTheme, { children: 'Test Button', size: ButtonSize.Big });
expect(container).toBeInTheDocument();
const button = screen.getByText('Test Button');
const buttonHeight = getComputedStyle(button.previousSibling as Element).getPropertyValue(
"height"
);
const buttonHeight = getComputedStyle(button.previousSibling as Element).getPropertyValue("height");
expect(buttonHeight).toEqual('40px');
userEvent.click(button);
expect(onClickMock).toHaveBeenCalled();
});

});
93 changes: 93 additions & 0 deletions src/components/action-icon-button/action-icon-button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import React, { useMemo } from "react";
belom88 marked this conversation as resolved.
Show resolved Hide resolved
import styled from "styled-components";
import { ButtonSize } from "../../types";
import { StyledComponent, DefaultTheme } from "styled-components";

import {
color_brand_tertiary,
} from "../../constants/colors";

const Button = styled.div<{ grayed?: boolean }>`
display: flex;
justify-content: flex-start;
align-items: center;
padding: 10px;
cursor: pointer;

&:hover {
> :first-child {
background: ${color_brand_tertiary}33;

> * {
fill: ${color_brand_tertiary};
}
}

> :nth-child(2) {
color: ${({ theme, grayed }) => (
grayed
? theme.colors.actionIconButtonTextDisabledColorHover
: color_brand_tertiary
)};
}
}
`;

const ButtonText = styled.div<{ grayed?: boolean }>`
belom88 marked this conversation as resolved.
Show resolved Hide resolved
position: relative;
margin-left: 16px;
color: ${({ theme, grayed }) => (
grayed
? theme.colors.actionIconButtonTextDisabledColor
: color_brand_tertiary
)};
`;

const IconContainer = styled.div<{ buttonSize: number, grayed?: boolean }>`
display: flex;
position: relative;
width: ${(props) => (props.buttonSize === ButtonSize.Big ? "40px" : "24px")};
height: ${(props) => (props.buttonSize === ButtonSize.Big ? "40px" : "24px")};

background: ${({ theme, grayed }) => (
grayed
? theme.colors.actionIconButtonDisabledBG
: `${color_brand_tertiary}66`
)};

border-radius: 4px;
align-items: center;
justify-content: center;
`;

type ActionIconButtonProps = {
children?: React.ReactNode;
Icon: StyledComponent<any, DefaultTheme, object, string | number | symbol>;
size: ButtonSize;
style?: "active" | "disabled";
onClick?: () => void;
};

export const ActionIconButton = ({ Icon, style, size, children, onClick }: ActionIconButtonProps) => {

const grayed = useMemo(() => style === "disabled", [style]);

const StyledIcon = styled(Icon) <{ grayed?: boolean }>`
position: absolute;
fill: ${({ theme, grayed }) => (
grayed
? theme.colors.actionIconButtonDisabledColor
: color_brand_tertiary
)};
`;
belom88 marked this conversation as resolved.
Show resolved Hide resolved

return (
<Button onClick={onClick} grayed={grayed}>
<IconContainer buttonSize={size} grayed={grayed}>
<StyledIcon grayed={grayed} />
</IconContainer>
<ButtonText grayed={grayed}>{children}</ButtonText>
</Button>
);
};

belom88 marked this conversation as resolved.
Show resolved Hide resolved
Loading