diff --git a/scripts/styleguide.config.js b/scripts/styleguide.config.js index c4886bd2f2..dbb2286537 100644 --- a/scripts/styleguide.config.js +++ b/scripts/styleguide.config.js @@ -103,6 +103,19 @@ const allSections = [ description: 'Box UI Elements components implement the reusable building blocks of the Box Design Language', sectionDepth: 2, usageMode: 'expand', + sections: [ + { + name: 'Media', + components: [ + '../src/components/media/Media.js', + '../src/components/media/MediaFigure.js', + '../src/components/media/MediaBody.js', + '../src/components/media/MediaMenu.js', + ], + description: 'Implements the "media object" layout', + usageMode: 'expand', + }, + ], }, { name: 'Icons', diff --git a/src/components/media/Media.js b/src/components/media/Media.js new file mode 100644 index 0000000000..0a314a0e4a --- /dev/null +++ b/src/components/media/Media.js @@ -0,0 +1,35 @@ +// @flow +import * as React from 'react'; +import classnames from 'classnames'; +import MediaFigure from './MediaFigure'; +import MediaBody from './MediaBody'; +import MediaMenu from './MediaMenu'; +import './Media.scss'; + +type Props = { + /** Component to use as outermost element, e.g., 'li' */ + as: React.ElementType, + /** Child elements */ + children: React.ChildrenArray>, + /** Additional class names */ + className?: string, +}; + +const Media = ({ as: Wrapper, children, className, ...rest }: Props) => ( + + {children} + +); + +// Use this instead of default value because of param destructuring bug in Flow +// that affects union types +// https://github.com/facebook/flow/issues/5461 +Media.defaultProps = { + as: 'div', +}; + +Media.Body = MediaBody; +Media.Menu = MediaMenu; +Media.Figure = MediaFigure; + +export default Media; diff --git a/src/components/media/Media.md b/src/components/media/Media.md new file mode 100644 index 0000000000..a88e50fb19 --- /dev/null +++ b/src/components/media/Media.md @@ -0,0 +1,148 @@ +> **Note** +> +> `Media` is a compound component, the inner elements are not meant to be used outside of the Media container + +Implements the "media object" element + +```plaintext +import Media from 'box-ui-elements/es/components/media' +``` + +```js +const { MenuItem } = require('../menu'); + + + + + + + + + Edit + Delete + +
+ Yo Yo Ma commented on this file +
+
+ Please review the notes +
a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 8 + 9 0 1 2 3 4 5 6 7 8 9 +
+
+
; +``` + +```js +const { MenuItem } = require('../menu'); + +<> + + Media{' '} + Media.Figure{' '} + Media.Body{' '} + Media.Menu + +
+
+ + + + + + + + Edit + Delete + +
+ Yo Yo Ma commented on this file +
+
+ Please review the notes +
a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 + 8 9 0 1 2 3 4 5 6 7 8 9 +
+
+
+; +``` + +## Nesting Media Components + +```js +const { MenuItem } = require('../menu'); + + + + + + + + + Edit + Delete + +
+ Yo Yo Ma commented on this file +
+
This is a nested media object
+
    + + + + + + +
    + Bjork replied +
    +
    I must agree!
    + + + + + + +
    + Bono replied +
    +
    Me too!
    +
    +
    +
    +
    +
+
+
; +``` + +## With Form Elements + +```js +const { MenuItem } = require('../menu'); + + + + + + + + + Edit + Delete + +
+ W.A. Mozart commented on this file +
+
Everyone get ready to perform the symphony tonight!
+
+ + +