Skip to content

Commit

Permalink
fix: Fix the dark theme in ThreatModel Print Preview page (#124)
Browse files Browse the repository at this point in the history
* fix: Fix the dark theme in ThreatModel Print Preview page

* chore: Fix the alignment of the theme toggle
  • Loading branch information
jessieweiyi authored Jul 8, 2024
1 parent 9c7a32e commit 61022ac
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 15 deletions.
4 changes: 4 additions & 0 deletions packages/threat-composer-app/.projen/deps.json

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

4 changes: 2 additions & 2 deletions packages/threat-composer-app/.projen/tasks.json

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

1 change: 1 addition & 0 deletions packages/threat-composer-app/package.json

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

Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,27 @@
See the License for the specific language governing permissions and
limitations under the License.
******************************************************************************************************************** */
/** @jsxImportSource @emotion/react */
import { ThreatModelView } from '@aws/threat-composer';
import Box from '@cloudscape-design/components/box';
import { Container } from '@cloudscape-design/components';
import * as awsui from '@cloudscape-design/design-tokens';
import { css } from '@emotion/react';
import { FC, useEffect, useMemo } from 'react';
import { useParams } from 'react-router-dom';

const styles = {
container: css({
'background': awsui.colorBackgroundContainerContent,
'width': '100vw',
'height': '100vh',
'&>div': {
border: 'none !important',
borderRadius: '0px !important',
boxShadow: 'none !important',
},
}),
};

const ThreatModelPreview: FC = () => {
const { dataKey } = useParams();

Expand All @@ -37,11 +53,11 @@ const ThreatModelPreview: FC = () => {
};
}, [dataKey]);

if (!data) {
return <Box>No content</Box>;
}

return <ThreatModelView composerMode='Full' data={data} isPreview />;
return (<div css={styles.container}>
<Container>
{data ? <ThreatModelView composerMode='Full' data={data} isPreview /> : <div>No content</div>}
</Container>
</div>);
};

export default ThreatModelPreview;
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@ import { css } from '@emotion/react';
import { useThemeContext } from '../ThemeProvider';

const styles = {
container: css({
height: '100%',
display: 'flex',
alignItems: 'center',
}),
svg: css({
color: 'grey !important',
fill: 'grey !important',
Expand All @@ -35,7 +30,7 @@ const styles = {

const ThemeToggle = () => {
const { theme, setTheme } = useThemeContext();
return (<div css={styles.container}>
return (<div>
<SpaceBetween direction="horizontal" size="xs">
<Toggle
onChange={({ detail }) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
See the License for the specific language governing permissions and
limitations under the License.
******************************************************************************************************************** */
/** @jsxImportSource @emotion/react */

import DeleteConfirmationDialog from '@aws-northstar/ui/components/DeleteConfirmationDialog';
import Alert from '@cloudscape-design/components/alert';
import Button from '@cloudscape-design/components/button';
Expand All @@ -25,6 +27,7 @@ import {
} from '@cloudscape-design/components/internal/events';
import Select, { SelectProps } from '@cloudscape-design/components/select';
import SpaceBetween from '@cloudscape-design/components/space-between';
import { css } from '@emotion/react';
import { FC, useMemo, useState, useCallback, PropsWithChildren } from 'react';
import { APP_MODE_IDE_EXTENSION } from '../../../configs';
import {
Expand All @@ -41,11 +44,23 @@ import {
} from '../../../customTypes';
import useImportExport from '../../../hooks/useExportImport';
import useRemoveData from '../../../hooks/useRemoveData';
import getMobileMediaQuery from '../../../utils/getMobileMediaQuery';
import isWorkspaceExample from '../../../utils/isWorkspaceExample';
import ThemeToggle from '../../generic/ThemeToggle';
import EditWorkspace from '../../workspaces/EditWorkspace';
import FileImport from '../../workspaces/FileImport';

const styles = {
themeToggle: css({
height: '100%',
display: 'flex',
alignItems: 'center',
[getMobileMediaQuery()]: {
display: 'none',
},
}),
};

export interface WorkspaceSelectorProps {
embededMode: boolean;
enabledExportAll?: boolean;
Expand Down Expand Up @@ -360,7 +375,7 @@ const WorkspaceSelector: FC<PropsWithChildren<WorkspaceSelectorProps>> = ({
onItemClick={handleMoreActions}
/>
)}
{appMode !== 'ide-extension' && composerMode === 'Full' && <ThemeToggle />}
{appMode !== 'ide-extension' && composerMode === 'Full' && <div css={styles.themeToggle}><ThemeToggle /></div>}
</SpaceBetween>
{fileImportModalVisible && (
<FileImport
Expand Down
1 change: 1 addition & 0 deletions projenrc/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class ThreatComposerReactAppProject extends ReactTypeScriptProject {
"@cloudscape-design/global-styles",
"@cloudscape-design/design-tokens",
"@aws-northstar/ui",
"@emotion/react",
"@uidotdev/usehooks",
"react-router-dom",
"uuid",
Expand Down
14 changes: 14 additions & 0 deletions yarn.lock

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

0 comments on commit 61022ac

Please sign in to comment.