-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '461-implement-styled-component-for-version-display-base…
…d-on-figma-design' into 'dev' Resolve "Implement Styled Component for Version Display Based on Figma Design" Closes #461 See merge request ergo/rosen-bridge/ui!384
- Loading branch information
Showing
8 changed files
with
159 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@rosen-bridge/ui-kit': patch | ||
--- | ||
|
||
Implement Version component to display versions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
'@rosen-bridge/watcher-app': patch | ||
'@rosen-bridge/guard-app': patch | ||
'@rosen-bridge/rosen-app': patch | ||
--- | ||
|
||
Integrated the Version component in the SideBar to display version information optimized for both desktop and mobile views. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import React, { FC, useEffect, useMemo, useRef, useState } from 'react'; | ||
|
||
import { useIsMobile } from '../../hooks'; | ||
import { styled } from '../../styling'; | ||
import { CircularProgress } from '../base'; | ||
|
||
interface VersionProps { | ||
label: string; | ||
value?: string; | ||
sub?: Array<{ label: string; value?: string }>; | ||
} | ||
|
||
const Root = styled('div', { | ||
name: 'RosenVersion', | ||
slot: 'Root', | ||
overridesResolver: (props, styles) => styles.root, | ||
})(({ theme }) => ({ | ||
display: 'flex', | ||
flexDirection: 'column', | ||
alignItems: 'center', | ||
justifyContent: 'start', | ||
fontWeight: '400px', | ||
fontSize: '12px', | ||
lineHeight: '14.06px', | ||
color: theme.palette.text.secondary, | ||
[theme.breakpoints.down('tablet')]: { | ||
flexDirection: 'row', | ||
justifyContent: 'start', | ||
position: 'absolute', | ||
left: '46px', | ||
top: '32px', | ||
lineHeight: '12px', | ||
gap: theme.spacing(1), | ||
}, | ||
})); | ||
|
||
export const Version: FC<VersionProps> = ({ label, value, sub }) => { | ||
const $timeout = useRef<number>(); | ||
|
||
const isMobile = useIsMobile(); | ||
|
||
const [timeout, setTimeout] = useState(false); | ||
|
||
const loaded = useMemo(() => { | ||
if (sub) { | ||
return !!value && !!sub.every((item) => !!item.value); | ||
} else { | ||
return !!value; | ||
} | ||
}, [value, sub]); | ||
|
||
const isLoading = !(loaded || timeout); | ||
|
||
useEffect(() => { | ||
clearTimeout($timeout.current); | ||
$timeout.current = window.setTimeout(() => { | ||
setTimeout(true); | ||
}, 15000); | ||
return () => { | ||
clearTimeout($timeout.current); | ||
}; | ||
}, [value, sub]); | ||
|
||
return ( | ||
<Root> | ||
{isLoading ? ( | ||
<CircularProgress sx={{ mt: 0.5 }} size={8} /> | ||
) : ( | ||
<> | ||
<span> | ||
{label} v{value || '?'} | ||
</span> | ||
{isMobile && sub ? ( | ||
<span> | ||
( | ||
{sub | ||
?.map((item) => `${item.label} v${item.value || '?'}`) | ||
.join(', ')} | ||
) | ||
</span> | ||
) : ( | ||
<> | ||
{sub?.map((item) => ( | ||
<span key={item.label}> | ||
{item.label} v{item.value || '?'} | ||
</span> | ||
))} | ||
</> | ||
)} | ||
</> | ||
)} | ||
</Root> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters