-
Notifications
You must be signed in to change notification settings - Fork 284
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8388 from google/enhancement/8137-add-info-notice
Add AudienceSegmentation/InfoNotice
- Loading branch information
Showing
10 changed files
with
223 additions
and
0 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
assets/js/modules/analytics-4/components/dashboard/AudienceSegmentation/InfoNotice.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/** | ||
* InfoNotice component. | ||
* | ||
* Site Kit by Google, Copyright 2024 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/** | ||
* External dependencies | ||
*/ | ||
import PropTypes from 'prop-types'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { Button } from 'googlesitekit-components'; | ||
import LightbulbIcon from '../../../../../../svg/icons/lightbulb.svg'; | ||
|
||
export default function InfoNotice( { content, dismissLabel, onDismiss } ) { | ||
return ( | ||
<div className="googlesitekit-audience-segmentation-info-notice"> | ||
<LightbulbIcon width="20" height="20" /> | ||
<div className="googlesitekit-audience-segmentation-info-notice__body"> | ||
<p>{ content }</p> | ||
|
||
{ dismissLabel && ( | ||
<Button | ||
tertiary | ||
onClick={ onDismiss } | ||
className="googlesitekit-audience-segmentation-info-notice__dismiss" | ||
> | ||
{ dismissLabel } | ||
</Button> | ||
) } | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
InfoNotice.propTypes = { | ||
content: PropTypes.string.isRequired, | ||
dismissLabel: PropTypes.string, | ||
onDismiss: PropTypes.func, | ||
}; |
42 changes: 42 additions & 0 deletions
42
...ts/js/modules/analytics-4/components/dashboard/AudienceSegmentation/InfoNotice.stories.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/** | ||
* InfoNotice Component Stories. | ||
* | ||
* Site Kit by Google, Copyright 2024 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import InfoNotice from './InfoNotice'; | ||
|
||
function Template( args ) { | ||
return <InfoNotice { ...args } />; | ||
} | ||
|
||
export const Default = Template.bind( {} ); | ||
Default.storyName = 'Default'; | ||
|
||
Default.args = { | ||
content: | ||
'The higher the portion of new visitors you have, the more your audience is growing. Looking at what content brings them to your site may give you insights on how to reach even more people.', | ||
dismissLabel: 'Got it', | ||
}; | ||
Default.scenario = { | ||
label: 'Modules/Analytics4/Components/AudienceSegmentation/InfoNotice/Default', | ||
}; | ||
|
||
export default { | ||
title: 'Modules/Analytics4/Components/AudienceSegmentation/InfoNotice', | ||
}; |
57 changes: 57 additions & 0 deletions
57
assets/js/modules/analytics-4/components/dashboard/AudienceSegmentation/InfoNotice.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/** | ||
* EnhancedMeasurementSwitch tests. | ||
* | ||
* Site Kit by Google, Copyright 2023 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { render } from '../../../../../../../tests/js/test-utils'; | ||
import InfoNotice from './InfoNotice'; | ||
|
||
describe( 'InfoNotice', () => { | ||
it( 'should render correctly in the default state', () => { | ||
const { container, getByText } = render( | ||
<InfoNotice | ||
content="Test content" | ||
dismissLabel="Test dismiss label" | ||
/> | ||
); | ||
|
||
expect( container ).toMatchSnapshot(); | ||
expect( getByText( 'Test content' ) ).toBeInTheDocument(); | ||
|
||
expect( getByText( 'Test dismiss label' ) ).toBeInTheDocument(); | ||
} ); | ||
|
||
it( 'should invoke the onDismiss callback when clicked', () => { | ||
const onClick = jest.fn(); | ||
|
||
const { getByText } = render( | ||
<InfoNotice | ||
content="Test content" | ||
dismissLabel="Test dismiss label" | ||
onDismiss={ onClick } | ||
/> | ||
); | ||
|
||
const button = getByText( 'Test dismiss label' ); | ||
|
||
button.click(); | ||
|
||
expect( onClick ).toHaveBeenCalledTimes( 1 ); | ||
} ); | ||
} ); |
28 changes: 28 additions & 0 deletions
28
...alytics-4/components/dashboard/AudienceSegmentation/__snapshots__/InfoNotice.test.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`InfoNotice should render correctly in the default state 1`] = ` | ||
<div> | ||
<div | ||
class="googlesitekit-audience-segmentation-info-notice" | ||
> | ||
<svg /> | ||
<div | ||
class="googlesitekit-audience-segmentation-info-notice__body" | ||
> | ||
<p> | ||
Test content | ||
</p> | ||
<button | ||
class="mdc-button googlesitekit-audience-segmentation-info-notice__dismiss mdc-button--tertiary" | ||
target="_self" | ||
> | ||
<span | ||
class="mdc-button__label" | ||
> | ||
Test dismiss label | ||
</span> | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...s/analytics-4/audience-segmentation/_googlesitekit-audience-segmentation-info-notice.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
.googlesitekit-audience-segmentation-info-notice { | ||
align-items: center; | ||
background-color: $c-surfaces-surface; | ||
border-radius: $br-sm; | ||
display: flex; | ||
gap: 20px; | ||
justify-content: space-between; | ||
padding: $grid-gap-phone; | ||
|
||
@media (min-width: $bp-desktop) { | ||
padding: $grid-gap-phone 40px; | ||
} | ||
|
||
svg { | ||
color: $c-yellow-y-100; | ||
flex-shrink: 0; | ||
} | ||
} | ||
|
||
.googlesitekit-audience-segmentation-info-notice__body { | ||
align-items: center; | ||
display: flex; | ||
flex-grow: 1; | ||
flex-wrap: wrap; | ||
gap: 0 60px; | ||
min-width: 0; | ||
|
||
p { | ||
flex-basis: 400px; | ||
flex-grow: 1; | ||
} | ||
} | ||
|
||
.googlesitekit-audience-segmentation-info-notice__dismiss { | ||
flex-shrink: 0; | ||
margin-left: auto; | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+17.4 KB
...tics4_Components_AudienceSegmentation_InfoNotice_Default_0_document_0_small.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+17.9 KB
...ics4_Components_AudienceSegmentation_InfoNotice_Default_0_document_1_medium.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+18.5 KB
...tics4_Components_AudienceSegmentation_InfoNotice_Default_0_document_2_large.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.