-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Added a not found view to product grid #2656
Changes from 3 commits
9e5441b
5c72673
2e95df2
467164e
1d84ac1
57bf7d6
9ac0fb6
5cf730e
1b173c8
98fca55
b08f506
99148e5
d1bca54
6c4c7db
98babd2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default as NotFound } from "./notFound"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import React from "react"; | ||
import PropTypes from "prop-types"; | ||
import classnames from "classnames"; | ||
import { Components, registerComponent } from "@reactioncommerce/reaction-components"; | ||
import { Icon } from "../icon"; | ||
|
||
/** | ||
* React component for displaying a not-found view | ||
* @param {props} props React props | ||
* @return {Node} React node containing not-found view | ||
*/ | ||
const NotFound = (props) => { | ||
// ClassName for base wrapper, | ||
// If one is provied in props, the default is not used | ||
const baseClassName = classnames({ | ||
"container-fluid-sm": typeof props.className === "undefined" | ||
}, props.className); | ||
|
||
// ClassName for content wrapper | ||
// If one is provied in props, the default is not used | ||
const contentClassName = classnames({ | ||
"empty-view-message": typeof props.contentClassName === "undefined" | ||
}, props.contentClassName); | ||
|
||
return ( | ||
<div className={baseClassName}> | ||
<div className={contentClassName}> | ||
{ props.icon && | ||
<Icon icon={props.icon} /> | ||
} | ||
|
||
{ props.title && | ||
<Components.Translation defaultValue={props.title} i18nKey={props.i18nKeyTitle} /> | ||
} | ||
|
||
{ props.message && | ||
<Components.Translation defaultValue={props.message} i18nKey={props.i18nKeyMessage} /> | ||
} | ||
|
||
{props.children} | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
NotFound.propTypes = { | ||
/** | ||
* Children | ||
* @type {ReactNode} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we make this more consistent? I feel like we call this different things different place (e.g. Node/ReactNode/JSX. Is there a difference?) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe just go with @machikoyasuda what do you think? Maybe we can set up a type in jsdoc that knows |
||
*/ | ||
children: PropTypes.node, | ||
|
||
/** | ||
* Baase wrapper className | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. typo in comment |
||
* @summary String className of `classnames` compatable object for the base wrapper | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. typo in comment |
||
* @type {String|Object} | ||
*/ | ||
className: PropTypes.oneOfType([PropTypes.string, PropTypes.object]), | ||
|
||
/** | ||
* Content className | ||
* @summary String className of `classnames` compatable object for the content wrapper | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. typo in comment (compatible) |
||
* @type {String|Object} | ||
*/ | ||
contentClassName: PropTypes.oneOfType([PropTypes.string, PropTypes.object]), | ||
|
||
/** | ||
* i18n key for message | ||
* @type {String} | ||
*/ | ||
i18nKeyMessage: PropTypes.string, | ||
|
||
/** | ||
* i18n key for title | ||
* @type {String} | ||
*/ | ||
i18nKeyTitle: PropTypes.string, | ||
|
||
/** | ||
* Icon name | ||
* @type {String} | ||
*/ | ||
icon: PropTypes.string, | ||
|
||
/** | ||
* Message text | ||
* @type {String} | ||
*/ | ||
message: PropTypes.string, | ||
|
||
/** | ||
* Title | ||
* @type {String} | ||
*/ | ||
title: PropTypes.string | ||
}; | ||
|
||
registerComponent("NotFound", NotFound); | ||
|
||
export default NotFound; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo in comment