Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# exclude vendored and generated files
package-lock.json linguist-generated
/src/stories/assets/** linguist-vendored
/storybook/stories/assets/** linguist-vendored
/docs/** linguist-documentation
18 changes: 0 additions & 18 deletions .storybook/main.js

This file was deleted.

37 changes: 0 additions & 37 deletions package-lock.json

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

6 changes: 3 additions & 3 deletions src/scripts/components/NoticesArea.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const NoticesArea = ( props ) => {
*/
if ( context === defaultContext ) {
/** Returns the empty notice banner whenever the number of notices is 0 */
if ( ! notifications.length ) {
if ( ! notifications?.length ) {
return <NoticeEmpty size={ 96 } message={ __( 'empty' ) } />;
}

Expand All @@ -65,9 +65,9 @@ export const NoticesArea = ( props ) => {
<NoticeHubSectionHeader
context={ context }
unreadCount={
notifications.filter(
notifications?.filter(
( notice ) => notice.status === 'new'
).length
).length || 0
}
isMain={ index === 0 } // the main section is the first one
/>
Expand Down
19 changes: 15 additions & 4 deletions src/scripts/components/NotificationHub.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { __ } from '@wordpress/i18n';
import { useEffect, useRef, useState } from '@wordpress/element';
import { useEffect, useRef } from '@wordpress/element';
import { useControlledState } from '@wordpress/components/build-module/utils';
import {
ShortcutProvider,
store as keyboardShortcutsStore,
Expand All @@ -9,9 +10,19 @@ import { Drawer } from './Drawer';
import { NotificationHubIcon } from './NotificationHubIcon';
import * as classNames from 'classnames';

export const NotificationHub = () => {
/**
* The notification hub component.
*
* @param {Object} props
* @param {boolean} props.active Externally supplied active state.
* @param {boolean=} props.initialActive Optionally initially force the hub into an active state.
*/
export const NotificationHub = ( { active, initialActive } ) => {
/** Drawer state */
const [ isActive, setIsActive ] = useState( false );
const [ isActive, setIsActive ] = useControlledState( active, {
initial: initialActive === undefined ? false : initialActive,
fallback: false,
} );
const drawerRef = useRef( null );

/** Register the keyboard shortcut(s) */
Expand All @@ -28,7 +39,7 @@ export const NotificationHub = () => {
} );

function toggleDrawer() {
setIsActive( ! isActive );
setIsActive( ( prev ) => ! prev );
}

const handleOutsideClick = ( event ) => {
Expand Down
69 changes: 0 additions & 69 deletions src/stories/Dash-multiple.stories.js

This file was deleted.

172 changes: 0 additions & 172 deletions src/stories/Hub-multiple.stories.js

This file was deleted.

Loading