diff --git a/.env b/.env
deleted file mode 100644
index 756b2061..00000000
--- a/.env
+++ /dev/null
@@ -1 +0,0 @@
-REACT_APP_ARCGIS_REST_CLIENT_ID=abcdef
diff --git a/.env-template b/.env-template
new file mode 100644
index 00000000..8f85508b
--- /dev/null
+++ b/.env-template
@@ -0,0 +1 @@
+REACT_APP_ARCGIS_REST_CLIENT_ID=abcd
diff --git a/.gitignore b/.gitignore
index eb7b4d44..8a67cf5e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
node_modules/
build/
coverage/
+.env
diff --git a/__mocks__/@esri/arcgis-rest-request.ts b/__mocks__/@esri/arcgis-rest-request.ts
new file mode 100644
index 00000000..391ef811
--- /dev/null
+++ b/__mocks__/@esri/arcgis-rest-request.ts
@@ -0,0 +1,26 @@
+const mockEmailExpected = "usermail@gmail.com";
+const mockSessionExpected = '{"usermail": "usermail"}';
+
+export class ArcGISIdentityManager {
+ static beginOAuth2 = async () => {
+ const session = {
+ usermail: mockEmailExpected,
+ serialize: () => {
+ return mockSessionExpected;
+ },
+ getUser: async () => {
+ return { email: mockEmailExpected };
+ },
+ };
+ return session;
+ };
+ static completeOAuth2 = async () => {
+ return;
+ };
+ static destroy = async () => {
+ return;
+ };
+ static deserialize = (session) => {
+ return { usermail: "usermail" };
+ };
+}
diff --git a/package.json b/package.json
index 9938aaa7..bd93774c 100644
--- a/package.json
+++ b/package.json
@@ -20,6 +20,8 @@
"author": "",
"license": "ISC",
"dependencies": {
+ "@esri/arcgis-rest-auth": "^3.7.0",
+ "@esri/arcgis-rest-request": "^4.2.0",
"@fortawesome/fontawesome-svg-core": "^1.2.36",
"@fortawesome/free-solid-svg-icons": "^5.15.4",
"@fortawesome/react-fontawesome": "^0.1.17",
diff --git a/public/icons/download-2.svg b/public/icons/download-2.svg
deleted file mode 100644
index bdfae70b..00000000
--- a/public/icons/download-2.svg
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
diff --git a/src/app.tsx b/src/app.tsx
index 43e316f1..a709d385 100644
--- a/src/app.tsx
+++ b/src/app.tsx
@@ -164,6 +164,7 @@ export const App = () => {
} />
} />
} />
+ } />
{
return renderFunc(
+ {...props}
+ />
);
};
-describe("Plus Button", () => {
- it("Should render small Plus button", () => {
- const { container } = callRender(renderWithTheme, { children: 'Test Button' });
+describe("ActionIconButton", () => {
+ it("Should render small Plus icon in the 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");
- expect(buttonHeight).toEqual('24px');
+ const button = screen.getByText("Test Button");
+ 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', size: ButtonSize.Big });
+ it("Should render Big Plus icon in the button", () => {
+ 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");
- expect(buttonHeight).toEqual('40px');
+ const button = screen.getByText("Test Button");
+ const buttonHeight = getComputedStyle(
+ button.previousSibling as Element
+ ).getPropertyValue("height");
+ expect(buttonHeight).toEqual("40px");
userEvent.click(button);
expect(onClickMock).toHaveBeenCalled();
});
-
});
diff --git a/src/components/action-icon-button/action-icon-button.tsx b/src/components/action-icon-button/action-icon-button.tsx
index 8e2b6433..c30690d3 100644
--- a/src/components/action-icon-button/action-icon-button.tsx
+++ b/src/components/action-icon-button/action-icon-button.tsx
@@ -1,10 +1,12 @@
import React from "react";
-import styled, { StyledComponent, DefaultTheme, useTheme } from "styled-components";
+import styled, {
+ StyledComponent,
+ DefaultTheme,
+ useTheme,
+} from "styled-components";
import { ButtonSize } from "../../types";
-import {
- color_brand_tertiary,
-} from "../../constants/colors";
+import { color_brand_tertiary } from "../../constants/colors";
const Button = styled.div<{ grayed?: boolean }>`
display: flex;
@@ -23,11 +25,10 @@ const Button = styled.div<{ grayed?: boolean }>`
}
> :nth-child(2) {
- color: ${({ theme, grayed }) => (
- grayed
- ? theme.colors.actionIconButtonTextDisabledColorHover
- : color_brand_tertiary
- )};
+ color: ${({ theme, grayed }) =>
+ grayed
+ ? theme.colors.actionIconButtonTextDisabledColorHover
+ : color_brand_tertiary};
}
}
`;
@@ -37,27 +38,25 @@ const ButtonText = styled.div<{ grayed?: boolean }>`
font-weight: 500;
font-size: 16px;
line-height: 19px;
- color: ${({ theme, grayed }) => (
+ color: ${({ theme, grayed }) =>
grayed
? theme.colors.actionIconButtonTextDisabledColor
- : color_brand_tertiary
- )};
- `;
+ : color_brand_tertiary};
+`;
-const IconContainer = styled.div<{ buttonSize: number, grayed?: boolean }>`
+const IconContainer = styled.div<{ buttonSize: number; grayed?: boolean }>`
display: flex;
justify-content: center;
align-items: center;
border-radius: 4px;
width: ${(props) => (props.buttonSize === ButtonSize.Big ? "40px" : "24px")};
height: ${(props) => (props.buttonSize === ButtonSize.Big ? "40px" : "24px")};
-
- background: ${({ theme, grayed }) => (
+
+ background: ${({ theme, grayed }) =>
grayed
? theme.colors.actionIconButtonDisabledBG
- : `${color_brand_tertiary}66`
- )};
- `;
+ : `${color_brand_tertiary}66`};
+`;
type ActionIconButtonProps = {
children?: React.ReactNode;
@@ -67,18 +66,30 @@ type ActionIconButtonProps = {
onClick?: () => void;
};
-export const ActionIconButton = ({ Icon, style, size, children, onClick }: ActionIconButtonProps) => {
+export const ActionIconButton = ({
+ Icon,
+ style,
+ size,
+ children,
+ onClick,
+}: ActionIconButtonProps) => {
const grayed = style === "disabled";
const theme = useTheme();
return (
-