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

ThreatsModal: Add bulk support #40692

Open
wants to merge 293 commits into
base: add/protect/core
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
293 commits
Select commit Hold shift + click to select a range
6c19fcd
Add actionToConfirm flag for rendering conditional content based on a…
dkmyta Nov 19, 2024
a134a4e
Update approach to single view
dkmyta Nov 20, 2024
c084a5f
Move notices to ThreatActions
dkmyta Nov 20, 2024
5533413
Rebase
dkmyta Nov 20, 2024
03eb1ba
Add fixer notices
dkmyta Nov 20, 2024
b33d1d1
Add fixer notices
dkmyta Nov 21, 2024
3541623
Fix styling
dkmyta Nov 21, 2024
0032d03
Additional improvements
dkmyta Nov 21, 2024
d028679
Fix gap
dkmyta Nov 21, 2024
daf8c58
Rebase
dkmyta Nov 21, 2024
a6d4c3a
Fix conflicts
dkmyta Nov 21, 2024
b7d60ff
Fix styles
dkmyta Nov 21, 2024
a67f639
Add ignore confirmation details
dkmyta Nov 21, 2024
962a992
Add modal fixer confirmation context
dkmyta Nov 21, 2024
5860eca
Reorg
dkmyta Nov 21, 2024
84bf4fd
Remove actionToConfirm flag, to be readded in integration
dkmyta Nov 21, 2024
344696a
Early return on ThreatActions for fixed threats
dkmyta Nov 21, 2024
baeaacf
Rebase
dkmyta Nov 21, 2024
242ca8f
Make threat status check optional
dkmyta Nov 21, 2024
6807ee6
Merge branch 'update/components/threat-details-modal-flow' into add/c…
dkmyta Nov 21, 2024
c01432f
Fix stories
dkmyta Nov 21, 2024
9151f92
Merge branch 'trunk' into update/components/threat-details-modal-flow
dkmyta Nov 21, 2024
f02fa61
Merge branch 'update/components/threat-details-modal-flow' into add/c…
dkmyta Nov 21, 2024
9093f0a
Fix tests
dkmyta Nov 21, 2024
a02bff6
Remove jest
dkmyta Nov 21, 2024
220d28c
Use custom button for threat details toggle (#40298)
nateweller Nov 22, 2024
896f7e0
Use Button and override internal styles
dkmyta Nov 22, 2024
41e563f
Fix classes
dkmyta Nov 22, 2024
94ed99a
Move fixerState comp to ThreatFixConfirmation
dkmyta Nov 22, 2024
33268ee
Rely heavily on context provider
dkmyta Nov 22, 2024
a68be5e
Rebase, fix stories
dkmyta Nov 22, 2024
1e2333e
Fix styles
dkmyta Nov 25, 2024
6815e0e
Merge branch 'update/components/threat-details-modal-flow' into add/c…
dkmyta Nov 25, 2024
538694f
Add support link
dkmyta Nov 25, 2024
e390d43
Fix threat action buttons in mobile
dkmyta Nov 25, 2024
572cc10
Merge trunk, fix conflicts
dkmyta Nov 25, 2024
b085648
changelog
dkmyta Nov 25, 2024
4daadc6
Fix focus styling issues
dkmyta Nov 25, 2024
1716a45
Add slight padding to overflow issues
dkmyta Nov 25, 2024
aa0f8e5
Add global override, over awkward title offset
dkmyta Nov 25, 2024
fbd7091
Remove unneeded styles while global override is in place
dkmyta Nov 25, 2024
bbb39c6
Rebase, fix conflicts
dkmyta Dec 3, 2024
a51c906
Fix text domain
dkmyta Dec 3, 2024
3a17f97
Init project branch
nateweller Nov 14, 2024
f4820b9
Protect: Add Go to Cloud and Scan now button to Protect primary heade…
dkmyta Nov 14, 2024
a240e20
Protect: Update Scan and History headers (#40058)
dkmyta Nov 14, 2024
b9bfed3
Protect: de-emphasize cloud link by using link variant (#40211)
nateweller Nov 18, 2024
f02081f
Protect: add ShieldIcon component
nateweller Nov 30, 2024
6c73d5a
Protect: Add ShieldIcon Component (#40402)
nateweller Dec 5, 2024
1118627
Protect: Integrate ThreatsDataViews Component (#40076)
nateweller Dec 5, 2024
5715d45
Merge branch 'add/protect/core' into add/components/threats-data-view…
dkmyta Dec 5, 2024
28310a8
Hook up ThreatModal integration in Protect
dkmyta Dec 5, 2024
3fc4a41
Revert changes to scan types until the expected type changes on the b…
dkmyta Dec 5, 2024
77fc70d
Add dummy arg
dkmyta Dec 5, 2024
39675ef
Add credentials polling while modal is open
dkmyta Dec 5, 2024
c3fa03f
Improve organization
dkmyta Dec 5, 2024
d24d492
Fix tests
dkmyta Dec 5, 2024
5ce9a33
Remove dummy arg
dkmyta Dec 6, 2024
49db999
Fix build errors
dkmyta Dec 6, 2024
4dd60b7
Init project branch
nateweller Nov 14, 2024
ff92d88
Protect: Add Go to Cloud and Scan now button to Protect primary heade…
dkmyta Nov 14, 2024
39e4094
Protect: Update Scan and History headers (#40058)
dkmyta Nov 14, 2024
9fec011
Protect: de-emphasize cloud link by using link variant (#40211)
nateweller Nov 18, 2024
af172c9
Protect: add ShieldIcon component
nateweller Nov 30, 2024
00283bc
Protect: Add ShieldIcon Component (#40402)
nateweller Dec 5, 2024
f580ace
Protect: Integrate ThreatsDataViews Component (#40076)
nateweller Dec 5, 2024
c384d69
Components: Add ScanReport (#40419)
dkmyta Dec 5, 2024
68569f2
Fix type errors
nateweller Dec 6, 2024
91ee20a
Protect: Refactor AdminSectionHero (#40516)
nateweller Dec 9, 2024
617b7d0
Rebase, add isSupportedEnvironment flag for displaying codeable redirect
dkmyta Dec 9, 2024
38c8904
Fix description text wrap
dkmyta Dec 9, 2024
5892e03
Restore history header
dkmyta Dec 10, 2024
ffb3ab0
Pass status filter presets to consumer
dkmyta Dec 10, 2024
3ad2ee8
Restore early return
dkmyta Dec 10, 2024
7ca9b41
Add plan level restrictions
dkmyta Dec 10, 2024
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
415573d
Rebase
dkmyta Dec 11, 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
50a7aa4
Rebase
dkmyta Dec 19, 2024
8e6488a
Reapply overwritten integration updates
dkmyta Dec 19, 2024
c607cd8
Add threats modal bulk variation
dkmyta Dec 19, 2024
35f40bd
Hide ignore details for free results
dkmyta Dec 19, 2024
be218b7
Optimize
dkmyta Dec 19, 2024
7d8b77a
Reapply actionToConfirm logic
dkmyta Dec 19, 2024
b73719b
Improvements and fixes
dkmyta Dec 19, 2024
204bf12
Update copy
dkmyta Dec 19, 2024
244ff4c
Add credentials status polling
dkmyta Dec 19, 2024
6368dad
Reorg and remove unused Protect modals
dkmyta Dec 19, 2024
5e22d9e
Align with Protect bulk modal structure, styling and functionality
dkmyta Dec 20, 2024
2e375de
Update stories for better clarifty on bulk usage
dkmyta Dec 20, 2024
51d1f89
Add story variations
dkmyta Dec 20, 2024
4d29bfa
Fix mobile styling
dkmyta Dec 20, 2024
f2dbed6
Rename vars, centralize shared constants, fix bulk item flex
dkmyta Dec 20, 2024
b62ad8a
Optimize
dkmyta Dec 20, 2024
b833f23
Update headings, improve mobile styling
dkmyta Dec 20, 2024
9177646
Further mobile adjustments
dkmyta Dec 20, 2024
289900f
Use computed label over title
dkmyta Dec 20, 2024
10f57c6
Reapply original title setup with now shortened content
dkmyta Dec 20, 2024
3baeb4f
Improve styles
dkmyta Dec 20, 2024
5601445
Fix console errors
dkmyta Dec 20, 2024
609a47e
Init project branch
nateweller Nov 14, 2024
43b9566
Protect: Add Go to Cloud and Scan now button to Protect primary heade…
dkmyta Nov 14, 2024
0f9d355
Protect: Update Scan and History headers (#40058)
dkmyta Nov 14, 2024
d7ec48a
Protect: de-emphasize cloud link by using link variant (#40211)
nateweller Nov 18, 2024
3195cb3
Protect: add ShieldIcon component
nateweller Nov 30, 2024
1b4eca4
Protect: Add ShieldIcon Component (#40402)
nateweller Dec 5, 2024
3d878c7
Protect: Integrate ThreatsDataViews Component (#40076)
nateweller Dec 5, 2024
e5d5b04
Components: Add ScanReport (#40419)
dkmyta Dec 5, 2024
7ef8809
Fix type errors
nateweller Dec 6, 2024
55a8d4f
Protect: Refactor AdminSectionHero (#40516)
nateweller Dec 9, 2024
f33e209
Protect: Update Scan History extension types (#40548)
dkmyta Dec 10, 2024
94c9c9a
Protect: Add Home page (#40317)
dkmyta Dec 10, 2024
88960de
Protect: Integrate ScanReport (#40420)
dkmyta Dec 11, 2024
62314b0
Fix duplicate imports
nateweller Dec 15, 2024
a0e7243
ScanReport: Fix defaultLayout (#40603)
dkmyta Dec 15, 2024
113e002
Update onboarding popover placement (#40550)
dkmyta Dec 15, 2024
338e67f
Protect Meets Core: Home Page Scan Report Data Adjustments (#40616)
nateweller Dec 18, 2024
484ce7c
Scan Report: Align Status Icon (#40617)
nateweller Dec 18, 2024
bbc2d56
Apply max width to hero content (#40618)
nateweller Dec 18, 2024
f3874ab
Protect: Hide Scan Report When No Data (#40619)
nateweller Dec 18, 2024
32bcff9
Protect: Hide Threats Report When No Data (#40620)
nateweller Dec 18, 2024
97f5c59
Protect: Update Threat Icons (#40621)
nateweller Dec 18, 2024
898ae2c
Protect: fix home page stat card spacing (#40623)
nateweller Dec 18, 2024
f2587f7
Fix ESLint issue
nateweller Jan 1, 2025
19d89e8
Use onClickItem over custom implementation to render modal on row click
dkmyta Jan 2, 2025
1db1e6c
ScanReport: Disable hiding relevant fields (#40602)
dkmyta Jan 2, 2025
2eba05f
Rebase
dkmyta Jan 2, 2025
56ad926
Use onChangeSelection for list view modal prompt
dkmyta Jan 2, 2025
e475334
Rebase
dkmyta Jan 2, 2025
8bd4c21
Rebase
dkmyta Jan 2, 2025
3dae6d4
Separate scan and history DataViews
dkmyta Jan 3, 2025
fbfe605
Reapply history routes
dkmyta Jan 3, 2025
f2bcbe7
Add filters
dkmyta Jan 3, 2025
4afa6fc
Add toggle group control
dkmyta Jan 3, 2025
6db0f6f
Add historic flag
dkmyta Jan 3, 2025
cdac95f
Update stories
dkmyta Jan 3, 2025
010b2c1
Remove unneeded filter handling
dkmyta Jan 3, 2025
c86dc12
Revert unnecessary threats data views updates
dkmyta Jan 3, 2025
d86c933
Fix import
dkmyta Jan 3, 2025
407e4ba
Add size prop
dkmyta Jan 3, 2025
f672f0a
Use error variant (#40832)
dkmyta Jan 3, 2025
1c72079
Merge branch 'add/protect/core' into restore/protect/history-admin-se…
dkmyta Jan 3, 2025
856479c
Rebase
dkmyta Jan 3, 2025
137f2a8
Include fixer action as label in list view action dropdown
dkmyta Jan 3, 2025
1c24e44
Add field constants
dkmyta Jan 3, 2025
8038593
Reorg
dkmyta Jan 3, 2025
ecd84a5
Init project branch
nateweller Nov 14, 2024
61f253e
Protect: Add Go to Cloud and Scan now button to Protect primary heade…
dkmyta Nov 14, 2024
61e9ce4
Protect: Update Scan and History headers (#40058)
dkmyta Nov 14, 2024
ecc1614
Protect: de-emphasize cloud link by using link variant (#40211)
nateweller Nov 18, 2024
5b90b11
Protect: add ShieldIcon component
nateweller Nov 30, 2024
cdcce9a
Protect: Add ShieldIcon Component (#40402)
nateweller Dec 5, 2024
3e0c385
Protect: Integrate ThreatsDataViews Component (#40076)
nateweller Dec 5, 2024
6db37a6
Components: Add ScanReport (#40419)
dkmyta Dec 5, 2024
179f46c
Fix type errors
nateweller Dec 6, 2024
ba9f82c
Protect: Refactor AdminSectionHero (#40516)
nateweller Dec 9, 2024
a0ef0da
Protect: Update Scan History extension types (#40548)
dkmyta Dec 10, 2024
8e64c51
Protect: Add Home page (#40317)
dkmyta Dec 10, 2024
f918ecc
Protect: Integrate ScanReport (#40420)
dkmyta Dec 11, 2024
c738c5e
Fix duplicate imports
nateweller Dec 15, 2024
a359d0e
ScanReport: Fix defaultLayout (#40603)
dkmyta Dec 15, 2024
18e3b91
Update onboarding popover placement (#40550)
dkmyta Dec 15, 2024
989641e
Protect Meets Core: Home Page Scan Report Data Adjustments (#40616)
nateweller Dec 18, 2024
0e4858a
Scan Report: Align Status Icon (#40617)
nateweller Dec 18, 2024
774e2a1
Apply max width to hero content (#40618)
nateweller Dec 18, 2024
d258efa
Protect: Hide Scan Report When No Data (#40619)
nateweller Dec 18, 2024
3afe1e9
Protect: Hide Threats Report When No Data (#40620)
nateweller Dec 18, 2024
bb6b8b2
Protect: Update Threat Icons (#40621)
nateweller Dec 18, 2024
f040e75
Protect: fix home page stat card spacing (#40623)
nateweller Dec 18, 2024
eb964dd
Fix ESLint issue
nateweller Jan 1, 2025
5476eef
ScanReport: Disable hiding relevant fields (#40602)
dkmyta Jan 2, 2025
8719eda
Use error variant (#40832)
dkmyta Jan 3, 2025
060637b
Protect: Restore HistoryAdminSectionHero (#40551)
dkmyta Jan 4, 2025
4068ba6
Add initialFields prop, update active to current where applicable
dkmyta Jan 6, 2025
19b7834
Rebase, fix conflicts
dkmyta Jan 6, 2025
90f99cd
Rebase
dkmyta Jan 7, 2025
f65e174
Fix exports and imports
dkmyta Jan 7, 2025
7db2fae
Fix conflicts
dkmyta Jan 7, 2025
edefa90
Add required props for HistoryDataViews, TODOs for optimizing
dkmyta Jan 7, 2025
7873c60
Extract alike items, optimize Protect DataViews components
dkmyta Jan 8, 2025
448ad40
Fix useConnection type error
dkmyta Jan 8, 2025
50aba98
Rebase
dkmyta Jan 8, 2025
e94e9a9
Fixes and improvements
dkmyta Jan 8, 2025
027cf57
Fix actionToConfirm, add TODO
dkmyta Jan 8, 2025
4f3edd5
Init project branch
nateweller Nov 14, 2024
3030bad
Protect: Add Go to Cloud and Scan now button to Protect primary heade…
dkmyta Nov 14, 2024
ab805e8
Protect: Update Scan and History headers (#40058)
dkmyta Nov 14, 2024
49d6d61
Protect: de-emphasize cloud link by using link variant (#40211)
nateweller Nov 18, 2024
7ea8f52
Protect: add ShieldIcon component
nateweller Nov 30, 2024
6dcdd5f
Protect: Add ShieldIcon Component (#40402)
nateweller Dec 5, 2024
075bc51
Protect: Integrate ThreatsDataViews Component (#40076)
nateweller Dec 5, 2024
e7bebc8
Components: Add ScanReport (#40419)
dkmyta Dec 5, 2024
7599733
Fix type errors
nateweller Dec 6, 2024
ca4e082
Protect: Refactor AdminSectionHero (#40516)
nateweller Dec 9, 2024
85c1b1b
Protect: Update Scan History extension types (#40548)
dkmyta Dec 10, 2024
b5e7652
Protect: Add Home page (#40317)
dkmyta Dec 10, 2024
dd6adbd
Protect: Integrate ScanReport (#40420)
dkmyta Dec 11, 2024
d13d57b
Fix duplicate imports
nateweller Dec 15, 2024
227f9d0
ScanReport: Fix defaultLayout (#40603)
dkmyta Dec 15, 2024
5f94f99
Update onboarding popover placement (#40550)
dkmyta Dec 15, 2024
84210ca
Protect Meets Core: Home Page Scan Report Data Adjustments (#40616)
nateweller Dec 18, 2024
568850a
Scan Report: Align Status Icon (#40617)
nateweller Dec 18, 2024
aacba30
Apply max width to hero content (#40618)
nateweller Dec 18, 2024
8959c09
Protect: Hide Scan Report When No Data (#40619)
nateweller Dec 18, 2024
3988095
Protect: Hide Threats Report When No Data (#40620)
nateweller Dec 18, 2024
133a718
Protect: Update Threat Icons (#40621)
nateweller Dec 18, 2024
c9f6be9
Protect: fix home page stat card spacing (#40623)
nateweller Dec 18, 2024
4744e1c
Fix ESLint issue
nateweller Jan 1, 2025
abdff30
ScanReport: Disable hiding relevant fields (#40602)
dkmyta Jan 2, 2025
506a4c0
Use error variant (#40832)
dkmyta Jan 3, 2025
9e6adfb
Protect: Restore HistoryAdminSectionHero (#40551)
dkmyta Jan 4, 2025
b5461e6
Protect: Separate scan results and history DataViews (#40845)
dkmyta Jan 14, 2025
e13a878
ThreatsDataViews: Improve responsiveness (#40670)
dkmyta Jan 14, 2025
18a23bc
Rebase, fix conflicts
dkmyta Jan 14, 2025
5a40215
Merge branch 'add/components/threats-data-views-modal-integration' in…
dkmyta Jan 14, 2025
4f21e75
Rebase, fix conflicts
dkmyta Jan 14, 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
  • Loading branch information
nateweller committed Jan 6, 2025
commit 5b90b11c650821cb1b3a7aa074e8935447d197f9
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import {
AdminSectionHero as JetpackAdminSectionHero,
H3,
getIconBySlug,
} from '@automattic/jetpack-components';
import { AdminSectionHero as JetpackAdminSectionHero, H3 } 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 @@ -15,7 +12,7 @@ interface AdminSectionHeroProps {
}

interface AdminSectionHeroComponent extends React.FC< AdminSectionHeroProps > {
Heading: React.FC< { children: React.ReactNode; showIcon?: boolean } >;
Heading: React.FC< { children: React.ReactNode; showIcon?: boolean; variant?: string } >;
Subheading: React.FC< { children: React.ReactNode } >;
}

Expand Down Expand Up @@ -44,17 +41,23 @@ const AdminSectionHero: AdminSectionHeroComponent = ( {

AdminSectionHero.Heading = ( {
children,
variant = 'default',
showIcon = false,
}: {
children: React.ReactNode;
variant?: 'default' | 'success' | 'error';
showIcon?: boolean;
} ) => {
const Icon = getIconBySlug( 'protect' );

return (
<H3 className={ styles.heading } mt={ 2 } mb={ 2 }>
{ children }
{ showIcon && <Icon className={ styles[ 'heading-icon' ] } size={ 32 } /> }
{ showIcon && (
<ShieldIcon
variant={ `${ variant }-outline` }
fill="#1d2327"
className={ styles[ 'heading-icon' ] }
/>
) }
</H3>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ Default.args = {
main: (
<>
<Status status={ 'active' } label={ 'Active' } />
<AdminSectionHero.Heading showIcon>{ 'No threats found' }</AdminSectionHero.Heading>
<AdminSectionHero.Heading showIcon variant="success">
{ 'No threats found' }
</AdminSectionHero.Heading>
<AdminSectionHero.Subheading>
<Text>{ 'Most recent results' }</Text>
</AdminSectionHero.Subheading>
Expand Down
165 changes: 165 additions & 0 deletions projects/plugins/protect/src/js/components/shield-icon/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
import { type JSX } from 'react';

/**
* Protect Shield and Checkmark SVG Icon
*
* @param {object} props - Component props.
* @param {string} props.variant - Icon variant.
* @param {string} props.fill - Icon fill color.
* @param {string} props.className - Additional class names.
* @param {number} props.height - Icon height.
* @return {JSX.Element} Protect Shield and Checkmark SVG Icon
*/
export default function ShieldIcon( {
variant = 'default',
height = 32,
className,
fill,
}: {
variant:
| 'default'
| 'success'
| 'error'
| 'default-outline'
| 'success-outline'
| 'error-outline';
className?: string;
height?: number;
fill?: string;
} ): JSX.Element {
if ( 'error-outline' === variant ) {
return (
<svg
height={ height }
width={ ( height * 18 ) / 23 }
viewBox="0 0 18 23"
fill="none"
xmlns="http://www.w3.org/2000/svg"
className={ className }
>
<path
fillRule="evenodd"
clipRule="evenodd"
d="M9 0.234863L18 4.32577V10.4242C18 15.6229 14.6611 20.545 9.95293 22.0978C9.33425 22.3019 8.66575 22.3019 8.04707 22.0978C3.33888 20.545 0 15.6229 0 10.4242V4.32577L9 0.234863ZM2 5.6136V10.4242C2 14.8415 4.86018 18.9408 8.67349 20.1985C8.88533 20.2683 9.11467 20.2683 9.32651 20.1985C13.1398 18.9408 16 14.8415 16 10.4242V5.6136L9 2.43178L2 5.6136Z"
fill={ fill || '#D63638' }
/>
<path
d="M8.22887 12.9258H9.78763L9.93608 7H8.08041L8.22887 12.9258ZM9.00825 16C9.57113 16 10.0165 15.5732 10.0165 15.0289C10.0165 14.4845 9.57113 14.0577 9.00825 14.0577C8.44536 14.0577 8 14.4845 8 15.0289C8 15.5732 8.44536 16 9.00825 16Z"
fill={ fill || '#D63638' }
/>
</svg>
);
}

if ( 'error' === variant ) {
return (
<svg
height={ height }
width={ ( height * 123 ) / 150 }
viewBox="0 0 123 150"
fill="none"
xmlns="http://www.w3.org/2000/svg"
className={ className }
>
<path
d="M61.364 0L0 27.273v40.909C0 106.023 26.182 141.409 61.364 150c35.182-8.591 61.363-43.977 61.363-81.818v-40.91L61.364 0z"
fill={ fill || '#D63638' }
/>
<path
d="M54.486 40.97h13.755v40.826H54.485V40.97zM54.486 95.55h13.755v13.48H54.485V95.55z"
fill={ `#fff` }
/>
</svg>
);
}

if ( 'success-outline' === variant ) {
return (
<svg
height={ height }
width={ ( height * 14 ) / 17 }
viewBox="0 0 14 17"
fill="none"
xmlns="http://www.w3.org/2000/svg"
className={ className }
>
<path
fillRule="evenodd"
clipRule="evenodd"
d="M7 0.17627L13.75 3.24445V7.8183C13.75 11.7173 11.2458 15.4089 7.7147 16.5735C7.2507 16.7265 6.7493 16.7265 6.2853 16.5735C2.75416 15.4089 0.25 11.7173 0.25 7.8183V3.24445L7 0.17627ZM1.75 4.21032V7.8183C1.75 11.1312 3.89514 14.2057 6.7551 15.149C6.914 15.2014 7.086 15.2014 7.2449 15.149C10.1049 14.2057 12.25 11.1312 12.25 7.8183V4.21032L7 1.82396L1.75 4.21032Z"
fill={ fill || '#069E08' }
/>
<path
fillRule="evenodd"
clipRule="evenodd"
d="M10.5291 7.0315L6.1818 11.358L3.47095 8.66L4.52907 7.5968L6.1818 9.2417L9.4709 5.96826L10.5291 7.0315Z"
fill={ fill || '#069E08' }
/>
</svg>
);
}

if ( 'success' === variant ) {
return (
<svg
height={ height }
width={ ( height * 80 ) / 96 }
viewBox="0 0 80 96"
fill="none"
xmlns="http://www.w3.org/2000/svg"
className={ className }
>
<path
fillRule="evenodd"
clipRule="evenodd"
d="M40 0.00634766L80 17.7891V44.2985C80 66.8965 65.1605 88.2927 44.2352 95.0425C41.4856 95.9295 38.5144 95.9295 35.7648 95.0425C14.8395 88.2927 0 66.8965 0 44.2985V17.7891L40 0.00634766Z"
fill={ fill || '#069E08' }
/>
<path
fillRule="evenodd"
clipRule="evenodd"
d="M60.9 33.6909L35.375 67.9124L19.2047 55.9263L22.7848 51.1264L34.1403 59.5436L56.0851 30.122L60.9 33.6909Z"
fill="white"
/>
</svg>
);
}

if ( 'default-outline' === variant ) {
return (
<svg
height={ height }
width={ ( height * 18 ) / 23 }
viewBox="0 0 18 23"
fill="none"
xmlns="http://www.w3.org/2000/svg"
className={ className }
>
<path
fillRule="evenodd"
clipRule="evenodd"
d="M9 0.234863L18 4.32577V10.4242C18 15.6229 14.6611 20.545 9.95293 22.0978C9.33425 22.3019 8.66575 22.3019 8.04707 22.0978C3.33888 20.545 0 15.6229 0 10.4242V4.32577L9 0.234863ZM2 5.6136V10.4242C2 14.8415 4.86018 18.9408 8.67349 20.1985C8.88533 20.2683 9.11467 20.2683 9.32651 20.1985C13.1398 18.9408 16 14.8415 16 10.4242V5.6136L9 2.43178L2 5.6136Z"
fill={ fill || 'black' }
/>
</svg>
);
}

return (
<svg
height={ height }
width={ ( height * 80 ) / 96 }
viewBox="0 0 80 96"
fill="none"
xmlns="http://www.w3.org/2000/svg"
className={ className }
>
<path
fillRule="evenodd"
clipRule="evenodd"
d="M40 0.00634766L80 17.7891V44.2985C80 66.8965 65.1605 88.2927 44.2352 95.0425C41.4856 95.9295 38.5144 95.9295 35.7648 95.0425C14.8395 88.2927 0 66.8965 0 44.2985V17.7891L40 0.00634766Z"
fill={ fill || 'black' }
/>
</svg>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import React from 'react';
import ShieldIcon from '../index';

export default {
title: 'Plugins/Protect/Sheild Icon',
component: ShieldIcon,
parameters: {
layout: 'centered',
},
decorators: [
Story => (
<div style={ { height: '72px', width: '72px' } }>
<Story />
</div>
),
],
argTypes: {
variant: {
control: {
type: 'select',
},
options: [
'default',
'success',
'error',
'default-outline',
'success-outline',
'error-outline',
],
},
fill: {
control: 'color',
},
},
};

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

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

export const ErrorVariant = args => <ShieldIcon { ...args } />;
ErrorVariant.args = {
variant: 'error',
};