Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
44f8f5b
Init project branch
nateweller Nov 14, 2024
01718e9
Protect: Add Go to Cloud and Scan now button to Protect primary heade…
dkmyta Nov 14, 2024
8937043
Protect: Update Scan and History headers (#40058)
dkmyta Nov 14, 2024
657dbef
Protect: de-emphasize cloud link by using link variant (#40211)
nateweller Nov 18, 2024
ddc735e
Protect: add ShieldIcon component
nateweller Nov 30, 2024
29e05eb
Protect: Add ShieldIcon Component (#40402)
nateweller Dec 5, 2024
f0fcba8
Protect: Integrate ThreatsDataViews Component (#40076)
nateweller Dec 5, 2024
d339c35
Components: Add ScanReport (#40419)
dkmyta Dec 5, 2024
983ef0c
Fix type errors
nateweller Dec 6, 2024
c91afb8
Protect: Refactor AdminSectionHero (#40516)
nateweller Dec 9, 2024
a9763ae
Protect: Update Scan History extension types (#40548)
dkmyta Dec 10, 2024
69648c8
Protect: Add Home page (#40317)
dkmyta Dec 10, 2024
cebc921
Protect: Integrate ScanReport (#40420)
dkmyta Dec 11, 2024
ccf0ed8
Fix duplicate imports
nateweller Dec 15, 2024
02a1f2e
ScanReport: Fix defaultLayout (#40603)
dkmyta Dec 15, 2024
4aff770
Update onboarding popover placement (#40550)
dkmyta Dec 15, 2024
4a9294b
Protect Meets Core: Home Page Scan Report Data Adjustments (#40616)
nateweller Dec 18, 2024
21b7ae1
Scan Report: Align Status Icon (#40617)
nateweller Dec 18, 2024
94732c6
Apply max width to hero content (#40618)
nateweller Dec 18, 2024
f6b6d75
Protect: Hide Scan Report When No Data (#40619)
nateweller Dec 18, 2024
7d5ad6e
Protect: Hide Threats Report When No Data (#40620)
nateweller Dec 18, 2024
f0dfecd
Protect: Update Threat Icons (#40621)
nateweller Dec 18, 2024
51f270f
Protect: fix home page stat card spacing (#40623)
nateweller Dec 18, 2024
fb68c51
Fix ESLint issue
nateweller Jan 1, 2025
3fa38b5
ScanReport: Disable hiding relevant fields (#40602)
dkmyta Jan 2, 2025
cb979da
Use error variant (#40832)
dkmyta Jan 3, 2025
e42e4ef
Protect: Restore HistoryAdminSectionHero (#40551)
dkmyta Jan 4, 2025
e181c22
Protect: Separate scan results and history DataViews (#40845)
dkmyta Jan 14, 2025
aa5b2a3
ThreatsDataViews: Improve responsiveness (#40670)
dkmyta Jan 14, 2025
193070d
ThreatsDataViews: ThreatModal integration (#40202)
dkmyta Jan 14, 2025
5eda38e
Protect Meets Core: Fix "0" rendered by conditional render chain (#40…
nateweller Jan 14, 2025
3af8b55
Fix: add missing return
nateweller Jan 16, 2025
c24ad4d
Fix: reduce of empty array with no initial value
nateweller Jan 16, 2025
94010c9
Fix: hide home report when first protect report scan initializing
nateweller Jan 16, 2025
6b592a9
minor adjustments
nateweller Jan 31, 2025
149ae4c
Update lockfile
nateweller Jan 31, 2025
eb000c5
Remove changes to protect-status package
nateweller Jan 31, 2025
35f474d
Remove changes to badge components, moved to #41450
nateweller Jan 31, 2025
b368b68
Fix type error
nateweller Feb 3, 2025
556e0f5
Fix stories
nateweller Feb 4, 2025
4a8d00b
Fix case where status.core is empty
nateweller Feb 4, 2025
6f73041
Spacing and sizing adjustments
nateweller Feb 5, 2025
5f2b0e8
Restore unintended webpack-cli version change
nateweller Feb 5, 2025
4953bd8
Fix ThreatsDataViews test
nateweller Feb 6, 2025
d3e68cf
changelog
nateweller Feb 9, 2025
138753d
Fix width of hero content
nateweller Feb 9, 2025
c03770c
Improve threat ignore/unignore queries
nateweller Feb 9, 2025
dc202f0
Remove close button from threat details modal actions
nateweller Feb 9, 2025
fa36e2b
Remove unneccessary changes to protect-status package
nateweller Feb 22, 2025
37fc1a0
Fix z-index conflict between Notice and DataViews components
nateweller Feb 22, 2025
1776bd1
Fix ThreatsDataViews title line wrapping
nateweller Feb 22, 2025
332009e
Add alternate 'how to fix it' message when no fixer or fixed in versi…
nateweller Feb 23, 2025
c44edb1
Fix imports and enhance types
nateweller Feb 23, 2025
aa98338
Additional import fixes and type improvements
nateweller Feb 23, 2025
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 Mar 22, 2025
commit 29e05ebc56aa111b735efa9a211fd273b63a109c
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/index.js';
export { default as ThreatFixerButton } from './components/threat-fixer-button/index.js';
export { default as ThreatSeverityBadge } from './components/threat-severity-badge/index.js';
export { default as ThreatsDataViews } from './components/threats-data-views/index.js';
export { default as ShieldIcon } from './components/shield-icon/index.js';
export { default as Text, H2, H3, Title } from './components/text/index.js';
export { default as ToggleControl } from './components/toggle-control/index.js';
export { default as NumberControl } from './components/number-control/index.js';
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