Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
3c24030
Init project branch
nateweller Nov 14, 2024
be99f50
Protect: Add Go to Cloud and Scan now button to Protect primary heade…
dkmyta Nov 14, 2024
8dd5dde
Protect: Update Scan and History headers (#40058)
dkmyta Nov 14, 2024
90d6898
Protect: de-emphasize cloud link by using link variant (#40211)
nateweller Nov 18, 2024
dd21913
Protect: add ShieldIcon component
nateweller Nov 30, 2024
19c083e
Protect: Add ShieldIcon Component (#40402)
nateweller Dec 5, 2024
08cdcb2
Protect: Integrate ThreatsDataViews Component (#40076)
nateweller Dec 5, 2024
0a9047e
Components: Add ScanReport (#40419)
dkmyta Dec 5, 2024
aa9b8a3
Fix type errors
nateweller Dec 6, 2024
08d8de3
Protect: Refactor AdminSectionHero (#40516)
nateweller Dec 9, 2024
b33c95a
Protect: Update Scan History extension types (#40548)
dkmyta Dec 10, 2024
e13aa74
Protect: Add Home page (#40317)
dkmyta Dec 10, 2024
322819d
Protect: Integrate ScanReport (#40420)
dkmyta Dec 11, 2024
b397656
Add custom field set when viewing historic threats
dkmyta Dec 11, 2024
8e1c8ae
Init project branch
nateweller Nov 14, 2024
8a3dc9b
Protect: Add Go to Cloud and Scan now button to Protect primary heade…
dkmyta Nov 14, 2024
1c4ba1e
Protect: Update Scan and History headers (#40058)
dkmyta Nov 14, 2024
ef21cc4
Protect: de-emphasize cloud link by using link variant (#40211)
nateweller Nov 18, 2024
2f37bfc
Protect: add ShieldIcon component
nateweller Nov 30, 2024
ffdc98c
Protect: Add ShieldIcon Component (#40402)
nateweller Dec 5, 2024
71384f1
Protect: Integrate ThreatsDataViews Component (#40076)
nateweller Dec 5, 2024
4fccd4c
Components: Add ScanReport (#40419)
dkmyta Dec 5, 2024
f172be7
Fix type errors
nateweller Dec 6, 2024
d25db57
Protect: Refactor AdminSectionHero (#40516)
nateweller Dec 9, 2024
e86cfe1
Protect: Update Scan History extension types (#40548)
dkmyta Dec 10, 2024
08d2ba1
Protect: Add Home page (#40317)
dkmyta Dec 10, 2024
48fba20
Protect: Integrate ScanReport (#40420)
dkmyta Dec 11, 2024
ef6e5d0
Fix duplicate imports
nateweller Dec 15, 2024
62838d3
ScanReport: Fix defaultLayout (#40603)
dkmyta Dec 15, 2024
a877b8c
Update onboarding popover placement (#40550)
dkmyta Dec 15, 2024
7a47485
Adjust approach
dkmyta Dec 16, 2024
87f5b71
Rebase
dkmyta Dec 16, 2024
130eaf4
Fix JSDocs
dkmyta Dec 17, 2024
b41b9d9
Init project branch
nateweller Nov 14, 2024
a33c2c8
Protect: Add Go to Cloud and Scan now button to Protect primary heade…
dkmyta Nov 14, 2024
405dee7
Protect: Update Scan and History headers (#40058)
dkmyta Nov 14, 2024
93dbb6a
Protect: de-emphasize cloud link by using link variant (#40211)
nateweller Nov 18, 2024
9c4161e
Protect: add ShieldIcon component
nateweller Nov 30, 2024
b50d50d
Protect: Add ShieldIcon Component (#40402)
nateweller Dec 5, 2024
91e17a5
Protect: Integrate ThreatsDataViews Component (#40076)
nateweller Dec 5, 2024
f51c991
Components: Add ScanReport (#40419)
dkmyta Dec 5, 2024
c39dada
Fix type errors
nateweller Dec 6, 2024
a5aad57
Protect: Refactor AdminSectionHero (#40516)
nateweller Dec 9, 2024
32e9291
Protect: Update Scan History extension types (#40548)
dkmyta Dec 10, 2024
bacace2
Protect: Add Home page (#40317)
dkmyta Dec 10, 2024
2a53e76
Protect: Integrate ScanReport (#40420)
dkmyta Dec 11, 2024
cc7d0a8
Fix duplicate imports
nateweller Dec 15, 2024
b204063
ScanReport: Fix defaultLayout (#40603)
dkmyta Dec 15, 2024
5c03069
Update onboarding popover placement (#40550)
dkmyta Dec 15, 2024
79761f7
Protect Meets Core: Home Page Scan Report Data Adjustments (#40616)
nateweller Dec 18, 2024
3756259
Scan Report: Align Status Icon (#40617)
nateweller Dec 18, 2024
4c5f0cd
Apply max width to hero content (#40618)
nateweller Dec 18, 2024
015561e
Protect: Hide Scan Report When No Data (#40619)
nateweller Dec 18, 2024
b7dcdc8
Protect: Hide Threats Report When No Data (#40620)
nateweller Dec 18, 2024
e971448
Protect: Update Threat Icons (#40621)
nateweller Dec 18, 2024
aac1879
Protect: fix home page stat card spacing (#40623)
nateweller Dec 18, 2024
a1018bf
Rebase
dkmyta Dec 18, 2024
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
Prev Previous commit
Next Next commit
Protect: Add ShieldIcon Component (#40402)
  • Loading branch information
nateweller committed Dec 15, 2024
commit ffdc98cfaefd2f9f538a70f08a2745da8302e1ac
4 changes: 4 additions & 0 deletions projects/js-packages/components/changelog/add-shield-icon
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: added

Add ShieldIcon component
79 changes: 79 additions & 0 deletions projects/js-packages/components/components/shield-icon/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import React from 'react';

const COLORS = {
error: '#D63638',
warning: '#F0B849',
success: '#069E08',
default: '#1d2327',
};

/**
* Protect Shield SVG Icon
*
* @param {object} props - Component props.
* @param {string} props.className - Additional class names.
* @param {string} props.contrast - Icon contrast color. Overrides variant.
* @param {string} props.fill - Icon fill color (default, success, warning, error, or a custom color code string). Overrides variant.
* @param {number} props.height - Icon height (px). Width is calculated based on height.
* @param {string} props.icon - Icon variant (success, error). Overrides variant.
* @param {boolean} props.outline - When enabled, the icon will use an outline style.
* @param {string} props.variant - Icon variant (default, success, error).
*
* @return {React.ReactElement} Protect Shield SVG Icon
*/
export default function ShieldIcon( {
className,
contrast = '#fff',
fill,
height = 32,
icon,
outline = false,
variant = 'default',
}: {
className?: string;
contrast?: string;
fill?: 'default' | 'success' | 'warning' | 'error' | string;
height?: number;
icon?: 'success' | 'error';
outline?: boolean;
variant: 'default' | 'success' | 'warning' | 'error';
} ): JSX.Element {
const shieldFill = COLORS[ fill ] || fill || COLORS[ variant ];
const iconFill = outline ? shieldFill : contrast;
const iconVariant = icon || variant;

return (
<svg
height={ height }
width={ ( height * 76 ) / 93 }
viewBox="0 0 76 93"
fill="none"
xmlns="http://www.w3.org/2000/svg"
className={ className }
>
<path
d={
'M37.5652 0.980293L75.1304 18.0554V43.5097C75.1304 65.2086 61.1942 85.753 41.5427 92.2343C38.9604 93.0862 36.1701 93.0862 33.5878 92.2343C13.9362 85.753 0 65.2086 0 43.5097V18.0554L37.5652 0.980293Z' +
( outline
? ' M8.34783 23.4307V43.5097C8.34783 61.9471 20.286 79.0573 36.2024 84.3068C37.0866 84.5981 38.0438 84.5981 38.928 84.3068C54.8444 79.0573 66.7826 61.9471 66.7826 43.5097V23.4307L37.5652 10.15L8.34783 23.4307Z'
: '' )
}
fill={ shieldFill }
/>
{ 'success' === iconVariant && (
<path
fillRule="evenodd"
clipRule="evenodd"
d="M55.6042 37.0675L34.3578 65.2656L20.898 55.3892L23.878 51.4342L33.33 58.3698L51.5965 34.1267L55.6042 37.0675Z"
fill={ iconFill }
/>
) }
{ [ 'warning', 'error' ].includes( iconVariant ) && (
<path
d="M41.7474 54.1614L43.0546 30H32L33.3071 54.1614H41.7474ZM41.4113 66.7283C42.3076 65.8681 42.7931 64.6713 42.7931 63.1378C42.7931 61.5669 42.345 60.3701 41.4487 59.5098C40.5523 58.6496 39.2452 58.2008 37.4899 58.2008C35.7346 58.2008 34.4275 58.6496 33.4939 59.5098C32.5602 60.3701 32.112 61.5669 32.112 63.1378C32.112 64.6713 32.5975 65.8681 33.5312 66.7283C34.5022 67.5886 35.8093 68 37.4899 68C39.1705 68 40.4776 67.5886 41.4113 66.7283Z"
fill={ iconFill }
/>
) }
</svg>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import ShieldIcon from '../index';

export default {
title: 'JS Packages/Components/Sheild Icon',
component: ShieldIcon,
parameters: {
layout: 'centered',
},
argTypes: {
variant: {
control: {
type: 'select',
},
options: [ 'default', 'success', 'warning', 'error' ],
},
icon: {
control: {
type: 'select',
},
options: [ 'success', 'error' ],
},
fill: {
control: 'color',
},
outline: {
control: 'boolean',
},
},
};

export const Default = args => <ShieldIcon { ...args } />;
Default.args = {
variant: 'success',
outline: false,
};

export const Variants = () => {
return (
<div style={ { display: 'flex', flexDirection: 'column', gap: '8px' } }>
<div style={ { display: 'flex', gap: '8px' } }>
<ShieldIcon variant="default" />
<ShieldIcon variant="success" />
<ShieldIcon variant="warning" />
<ShieldIcon variant="error" />
</div>
<div style={ { display: 'flex', gap: '8px' } }>
<ShieldIcon variant="default" outline />
<ShieldIcon variant="success" outline />
<ShieldIcon variant="warning" outline />
<ShieldIcon variant="error" outline />
</div>
</div>
);
};
1 change: 1 addition & 0 deletions projects/js-packages/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export { default as ThemeProvider } from './components/theme-provider';
export { default as ThreatFixerButton } from './components/threat-fixer-button';
export { default as ThreatSeverityBadge } from './components/threat-severity-badge';
export { default as ThreatsDataViews } from './components/threats-data-views';
export { default as ShieldIcon } from './components/shield-icon';
export { default as Text, H2, H3, Title } from './components/text';
export { default as ToggleControl } from './components/toggle-control';
export { default as numberFormat } from './components/number-format';
Expand Down
5 changes: 5 additions & 0 deletions projects/plugins/protect/changelog/refactor-alert-icon
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: changed
Comment: Refactored icon component code.


Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { AdminSectionHero as JetpackAdminSectionHero, H3 } from '@automattic/jetpack-components';
import {
AdminSectionHero as JetpackAdminSectionHero,
H3,
ShieldIcon,
} from '@automattic/jetpack-components';
import SeventyFiveLayout from '../seventy-five-layout';
import ShieldIcon from '../shield-icon';
import AdminSectionHeroNotices from './admin-section-hero-notices';
import styles from './styles.module.scss';

Expand All @@ -12,7 +15,12 @@ interface AdminSectionHeroProps {
}

interface AdminSectionHeroComponent extends React.FC< AdminSectionHeroProps > {
Heading: React.FC< { children: React.ReactNode; showIcon?: boolean; variant?: string } >;
Heading: React.FC< {
children: React.ReactNode;
showIcon?: boolean;
variant?: 'default' | 'success' | 'error';
outline?: boolean;
} >;
Subheading: React.FC< { children: React.ReactNode } >;
}

Expand Down Expand Up @@ -53,8 +61,10 @@ AdminSectionHero.Heading = ( {
{ children }
{ showIcon && (
<ShieldIcon
variant={ `${ variant }-outline` }
fill="#1d2327"
height={ 38 }
variant={ variant }
outline
fill="default"
className={ styles[ 'heading-icon' ] }
/>
) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
}

.heading-icon {
margin-left: var( --spacing-base ); // 8px
margin-left: calc( var( --spacing-base ) * 1.5 ); // 12px
margin-bottom: calc( var( --spacing-base ) / 2 * -1 ); // -4px
}

Expand All @@ -23,4 +23,4 @@

.connection-error-col {
margin-top: calc( var( --spacing-base ) * 3 + 1px ); // 25px
}
}
74 changes: 0 additions & 74 deletions projects/plugins/protect/src/js/components/alert-icon/index.jsx

This file was deleted.

This file was deleted.

This file was deleted.

Loading