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

Fix/#1339 consolidate spinners #1395

Merged
merged 3 commits into from
Nov 24, 2020
Merged
Show file tree
Hide file tree
Changes from 2 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
19 changes: 19 additions & 0 deletions app/src/components/common/icons/IconSpinner2.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from 'react'

interface Props {
spinnerSize?: string
}

export const IconSpinner = (props: Props) => {
Mi-Lan marked this conversation as resolved.
Show resolved Hide resolved
const { spinnerSize = '40' } = props
return (
<svg fill="none" height={spinnerSize} viewBox="0 0 40 40" width={spinnerSize} xmlns="http://www.w3.org/2000/svg">
<circle cx="20" cy="20" r="19" stroke="#E8EAF6" strokeWidth="2" />
<path
d="M20 39C30.4934 39 39 30.4934 39 20C39 9.50659 30.4934 1 20 1C9.50659 1 1 9.50659 1 20"
stroke="#3F51B5"
strokeWidth="2"
/>
</svg>
)
}
1 change: 1 addition & 0 deletions app/src/components/common/icons/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ export { IconSearchGrey } from './IconSearchGrey'
export { IconKleros } from './IconKleros'
export { IconExclamation } from './IconExclamation'
export { IconSchedule } from './IconSchedule'
export { IconSpinner } from './IconSpinner2'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about renaming this file from IconSpinner2 to just IconSpinner?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well that's where i had problem i don't know why but when i rename it to just IconSpinner it converts to like text file and it's not usable...

Copy link
Contributor Author

@Mi-Lan Mi-Lan Nov 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hexyls
Screenshot 2020-11-24 at 12 27 49
here is my concern when i change the name you see how IconSpinner next to it it's like text file and also this error like it's not exported good...i changed it for now but would be good if someone could test it on their machine...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this just an issue with your IDE identifying the file type? Seems to work fine for me

26 changes: 6 additions & 20 deletions app/src/components/common/spinner/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import React, { HTMLAttributes } from 'react'
import styled, { keyframes } from 'styled-components'

import SpinnerSVG from './img/spinnerMain.svg'
Mi-Lan marked this conversation as resolved.
Show resolved Hide resolved
import SpinnerBigSVG from './img/spinnerMainBig.svg'
import { IconSpinner } from '../icons'

const rotate = keyframes`
from {
Expand All @@ -13,37 +12,24 @@ const rotate = keyframes`
}
`

const RotatingSpinner = styled.div<{ height: string | undefined; width: string | undefined }>`
const RotatingSpinner = styled.div`
animation: ${rotate} 2s linear infinite;
flex-grow: 0;
flex-shrink: 0;
height: ${props => props.height};
width: ${props => props.width};
`

RotatingSpinner.defaultProps = {
height: '42px',
width: '42px',
}

const SpinnerIcon = styled.img`
height: 100%;
width: 100%;
`

interface Props extends HTMLAttributes<HTMLDivElement> {
color?: string
height?: string | undefined
width?: string | undefined
size?: string
big?: boolean | undefined
}

export const Spinner: React.FC<Props> = (props: Props) => {
const { big, color = '#fff', height, width, ...restProps } = props
const { big, color = '#fff', size, ...restProps } = props
Mi-Lan marked this conversation as resolved.
Show resolved Hide resolved

return (
<RotatingSpinner color={color} height={height} width={width} {...restProps}>
<SpinnerIcon alt="Loading..." src={big ? SpinnerBigSVG : SpinnerSVG} />
<RotatingSpinner color={color} {...restProps}>
<IconSpinner spinnerSize={big ? '42' : size ? size : '40'} />
</RotatingSpinner>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export const CurrencySelector: React.FC<Props> = props => {
dropdownPosition={DropdownPosition.center}
items={currencyDropdownData}
maxHeight={true}
placeholder={currency && currentItem === undefined ? <Spinner height={'18px'} width={'18px'} /> : placeholder}
placeholder={currency && currentItem === undefined ? <Spinner size="18" /> : placeholder}
selected={false}
/>
</Wrapper>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export const ModalCollateral = (props: Props) => {
}

const spinner = () => {
return isSpinnerOn && <SpinnerStyled height={'25px'} width={'25px'} />
return isSpinnerOn && <SpinnerStyled size="25" />
}

const tokenDetails = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ export const ImportMarketContent = (props: Props) => {
<EmptyWrapper>
{state.loading && (
<>
<SpinnerStyled height={'38px'} width={'38px'} />
<SpinnerStyled size="38" />
<CommentLabel>
importing market from{' '}
<a href={realitioBaseUrl} target="_blink">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ const MarketVerifyWrapper: React.FC<Props> = (props: Props) => {
<MarketVerification>
{loading || !data ? (
<CurationRow>
<CustomInlineLoading big message="Loading Curation Services" />
<CustomInlineLoading message="Loading Curation Services" />
</CurationRow>
) : (
<>
Expand Down