Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3406987
D10610.id35803.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D10610.id35803.diff
View Options
diff --git a/web/app-list/app-list-header.react.js b/web/app-list/app-list-header.react.js
--- a/web/app-list/app-list-header.react.js
+++ b/web/app-list/app-list-header.react.js
@@ -4,8 +4,7 @@
import { useModalContext } from 'lib/components/modal-provider.react.js';
-import css from './app-list-header.css';
-import AddButton from '../components/add-button.react.js';
+import PanelHeader from '../components/panel-header.react.js';
import AppsDirectory from '../modals/apps/apps-directory-modal.react.js';
function AppListHeader(): React.Node {
@@ -16,12 +15,7 @@
[pushModal],
);
- return (
- <div className={css.container}>
- <div className={css.headerLabel}>Your apps</div>
- <AddButton onClick={onClickApps} />
- </div>
- );
+ return <PanelHeader headerLabel="Your apps" onClickAddButton={onClickApps} />;
}
export default AppListHeader;
diff --git a/web/app-list/app-list-header.css b/web/components/panel-header.css
rename from web/app-list/app-list-header.css
rename to web/components/panel-header.css
--- a/web/app-list/app-list-header.css
+++ b/web/components/panel-header.css
@@ -2,7 +2,8 @@
display: flex;
justify-content: space-between;
align-items: center;
- padding: 16px;
+ padding: 0 16px;
+ height: 100%;
}
.headerLabel {
diff --git a/web/components/panel-header.react.js b/web/components/panel-header.react.js
new file mode 100644
--- /dev/null
+++ b/web/components/panel-header.react.js
@@ -0,0 +1,37 @@
+// @flow
+
+import * as React from 'react';
+
+import css from './panel-header.css';
+import AddButton from '../components/add-button.react.js';
+
+type Props = {
+ +headerLabel: string,
+ +onClickAddButton?: () => mixed,
+};
+
+function PanelHeader(props: Props): React.Node {
+ const { headerLabel, onClickAddButton } = props;
+
+ const addButton = React.useMemo(() => {
+ if (!onClickAddButton) {
+ return null;
+ }
+
+ return <AddButton onClick={onClickAddButton} />;
+ }, [onClickAddButton]);
+
+ const panelHeader = React.useMemo(
+ () => (
+ <div className={css.container}>
+ <div className={css.headerLabel}>{headerLabel}</div>
+ {addButton}
+ </div>
+ ),
+ [addButton, headerLabel],
+ );
+
+ return panelHeader;
+}
+
+export default PanelHeader;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Dec 5, 3:44 AM (14 h, 56 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2614401
Default Alt Text
D10610.id35803.diff (2 KB)
Attached To
Mode
D10610: [web] introduce panel header component
Attached
Detach File
Event Timeline
Log In to Comment