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

add upgrade cadence 1.0 banner #761

Merged
merged 5 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions src/components/Editor/index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Project } from 'api/apollo/generated/graphql';
import CookieDetector from 'components/BrowserDetector';
import FileExplorer from 'components/Editor/FileExplorer';
import TopNav from 'components/TopNav';
import UnsupportedMessage from 'components/UnsupportedBrowser';
import { EditorContainer } from 'containers/Playground/components';
import { ActiveEditor } from 'providers/Project';
import React from 'react';
import ErrorToastContainer from './ErrorToastContainer';
import Header from 'components/TopNav/Header';

const { detect } = require('detect-browser');
const browser = detect();
Expand All @@ -17,6 +17,7 @@ type EditorContainerProps = {
isLoading: boolean;
project: Project;
active: ActiveEditor;
isAnnouncementVisible: boolean;
};

const Editor = ({
Expand All @@ -25,13 +26,14 @@ const Editor = ({
isLoading,
project,
active,
isAnnouncementVisible,
}: EditorContainerProps) => {
return (
<>
{browser && browser.name === 'safari' ? (
<UnsupportedMessage />
) : (
<TopNav />
<Header isAnnouncementVisible={isAnnouncementVisible} />
)}
<CookieDetector />
<FileExplorer
Expand Down
61 changes: 61 additions & 0 deletions src/components/TopNav/Announcement.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import React from 'react';
import { SXStyles } from 'src/types';
import { Box, Flex, Link, useThemeUI } from 'theme-ui';

const Announcement = () => {
const context = useThemeUI();
const { theme } = context;

const styles: SXStyles = {
root: {
backgroundColor: 'white',
flex: '1 1 auto',
flexDirection: 'column',
alignItems: 'center',
justifyContent: 'space-between',
background: '#F27360',
width: '100%',
padding: '0.25rem 0 0.5rem',
height: '60px',
color: `${theme.colors.secondary}`,
},
message: {
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
textAlign: 'center',
color: `${theme.colors.secondary}`,
fontSize: '14px',
padding: '0.15rem',
},
devLink: {
textDecoration: 'underline',
color: `${theme.colors.secondary}`,
},
};

return (
<Flex sx={styles.root}>
<Box sx={styles.message}>⚠ Upgrade to Cadence 1.0</Box>
<Box sx={styles.message}>
The Crescendo network upgrade, including Cadence 1.0, is coming soon.
You most likely need to update all your contracts/transactions/scripts
to support this change.
</Box>
<Box sx={styles.message}>
Please visit our migration guide here:&nbsp;&nbsp;
<Link
sx={styles.devLink}
target="_blank"
href="https://developers.flow.com/build/cadence-migration-guide"
rel="noreferrer"
title="Report a Bug"
>
https://developers.flow.com/build/cadence-migration-guide
</Link>
</Box>
</Flex>
);
};

export default Announcement;
27 changes: 27 additions & 0 deletions src/components/TopNav/Header.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React from 'react';
import AnnouncementBar from './Announcement';
import TopNav from '.';
import { isMobile } from '../Editor/CadenceEditor/ControlPanel/utils';

const headerStyle: React.CSSProperties = {
display: 'flex',
gridArea: 'header',
flexDirection: 'column' as 'column',
alignItems: 'center',
justifyContent: 'left',
};

const Header = ({
isAnnouncementVisible,
}: {
isAnnouncementVisible: boolean;
}) => {
return (
<header style={headerStyle}>
{!isMobile() && isAnnouncementVisible && <AnnouncementBar />}
<TopNav />
</header>
);
};

export default Header;
2 changes: 1 addition & 1 deletion src/components/TopNav/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ const TopNav = () => {
const styles: SXStyles = {
root: {
display: 'flex',
gridArea: 'header',
flex: '1 1 auto',
alignItems: 'center',
justifyContent: 'space-between',
paddingLeft: '1em',
paddingRight: '1em',
background: `${theme.colors.primary}`,
width: '100%',
},
mobile: {
background: `${theme.colors.secondaryBackground}`,
Expand Down
3 changes: 3 additions & 0 deletions src/containers/Playground/EditorLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ import Editor from '../../components/Editor/index';
type EditorLayoutProps = {
isExplorerCollapsed: boolean;
toggleExplorer: () => void;
isAnnouncementVisible: boolean;
};

const EditorLayout = ({
isExplorerCollapsed,
toggleExplorer,
isAnnouncementVisible,
}: EditorLayoutProps) => {
const { project, isLoading, active } = useProject();

Expand Down Expand Up @@ -54,6 +56,7 @@ const EditorLayout = ({
isLoading={isLoading}
project={project}
active={active}
isAnnouncementVisible={isAnnouncementVisible}
/>
</>
);
Expand Down
9 changes: 7 additions & 2 deletions src/containers/Playground/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,15 @@ const closeLeftSidebarButtonStyle: CSSProperties = {
zIndex: 10,
};

const isAnnouncementVisible = true;

const getBaseStyles = (
showProjectsSidebar: boolean,
isExplorerCollapsed: boolean,
): ThemeUICSSObject => {
const fileExplorerWidth = isExplorerCollapsed
? isMobile()
? '30px'
? '50px'
: '65px'
: '244px';

Expand All @@ -57,7 +59,9 @@ const getBaseStyles = (
display: 'grid',
gridTemplateAreas: "'header header' 'sidebar main'",
gridTemplateColumns: `[sidebar] ${fileExplorerWidth} [main] auto`,
gridTemplateRows: ['40px auto', '50px auto'],
gridTemplateRows: isAnnouncementVisible
? ['40px auto', '105px auto']
: ['40px auto', '50px auto'],
overflow: 'hidden',
filter: showProjectsSidebar ? 'blur(1px)' : 'none',
};
Expand Down Expand Up @@ -115,6 +119,7 @@ const Content = () => {
<EditorLayout
isExplorerCollapsed={isExplorerCollapsed}
toggleExplorer={toggleExplorer}
isAnnouncementVisible={isAnnouncementVisible}
/>
</Box>
</motion.div>
Expand Down