diff --git a/example/src/App.js b/example/src/App.js index fb2c70d..0cd443e 100644 --- a/example/src/App.js +++ b/example/src/App.js @@ -2,6 +2,9 @@ import React, { Component } from "react"; import HalUI from "@diaas/hal-ui"; import "./App.css"; +const API_PROFILE_ID = ""; // From DXC Developer Central +const API_USER_NAME = ""; // From DXC Developer Central +const YOUR_API_KEY = ""; // From DXC Developer Central class App extends Component { state = { actions: [] }; @@ -12,20 +15,16 @@ class App extends Component { More information at https://developer.dxc.com/api/insurance/life/integral-prospects/codelab */ - const API_PROFILE_ID =""; // From DXC Developer Central - const API_USER_NAME = ""; // From DXC Developer Central - const YOUR_API_KEY = ""; // From DXC Developer Central - urlProspects = "https://api.dxc-dev-integral.hub-1.dev.us.insurance.dxc.com/prospects"; headersProspects = { - 'Content-Type': 'application/json', - 'Accept': 'application/json', - 'x-api-key': YOUR_API_KEY, - 'userName': API_USER_NAME, - 'profileid': API_PROFILE_ID - } + "Content-Type": "application/json", + Accept: "application/json", + "x-api-key": YOUR_API_KEY, + userName: API_USER_NAME, + profileid: API_PROFILE_ID, + }; render() { return ( diff --git a/lib/src/common/utils.js b/lib/src/common/utils.js new file mode 100644 index 0000000..eab996a --- /dev/null +++ b/lib/src/common/utils.js @@ -0,0 +1,39 @@ +import { useState, useEffect } from "react"; + +export const responsiveSizes = { + mobileSmall: "320", + mobileMedium: "375", + mobileLarge: "425", + tablet: "768", + laptop: "1024", + desktop: "1440", +}; + +export const useScreenType = () => { + const [screenType, setScreenType] = useState(); + + const handleResize = () => { + let type = "desktop"; + + if ( + document.documentElement.clientWidth > responsiveSizes.mobileLarge && + document.documentElement.clientWidth <= responsiveSizes.tablet + ) { + type = "tablet"; + } else if (document.documentElement.clientWidth <= responsiveSizes.mobileLarge) { + type = "mobile"; + } + setScreenType(type); + }; + + useEffect(() => { + window.addEventListener("resize", handleResize); + handleResize(); + + return () => { + window.removeEventListener("resize", handleResize); + }; + }, []); + + return screenType; +}; diff --git a/lib/src/hal-ui/HalUI.jsx b/lib/src/hal-ui/HalUI.jsx index cfe1191..d37db3b 100644 --- a/lib/src/hal-ui/HalUI.jsx +++ b/lib/src/hal-ui/HalUI.jsx @@ -126,7 +126,7 @@ const ErrorMessage = styled.div` `; const EmptyList = styled.div` - background-color: #d8d8d8; + background-color: #eee; text-align: center; padding: 20px; color: #545454; diff --git a/lib/src/hal-ui/InputPropertiesList.jsx b/lib/src/hal-ui/InputPropertiesList.jsx index 44494dc..79dccfb 100644 --- a/lib/src/hal-ui/InputPropertiesList.jsx +++ b/lib/src/hal-ui/InputPropertiesList.jsx @@ -2,13 +2,9 @@ import React from "react"; import styled from "styled-components"; import InputProperty from "./InputProperty.jsx"; -const InputPropertiesList = ({ - properties, - disabled, - propertyUpdateFunction -}) => ( +const InputPropertiesList = ({ properties, disabled, propertyUpdateFunction }) => ( - {properties.map(property => ( + {properties.map((property) => (