├── .editorconfig
├── .eslintignore
├── .eslintrc
├── .gitignore
├── CHANGELOG.md
├── README.md
├── bower.json
├── dist
├── react-media-object.js
└── react-media-object.min.js
├── example
└── src
│ ├── .gitignore
│ ├── example.js
│ ├── example.less
│ └── index.html
├── gulpfile.js
├── lib
├── Bd.js
├── Img.js
├── ImgExt.js
├── Media.js
├── ReactMediaObject.js
└── utils
│ └── styleResolver.js
├── package.json
├── src
├── Bd.js
├── Img.js
├── ImgExt.js
├── Media.js
├── ReactMediaObject.js
└── utils
│ └── styleResolver.js
└── test
├── .eslintrc
├── .gitkeep
├── Bd-test.js
├── Img-test.js
├── ImgExt-test.js
├── Media-test.js
├── mocha.opts
├── styleResolver-test.js
└── utils
└── document.js
/.editorconfig:
--------------------------------------------------------------------------------
1 | # This file is for unifying the coding style for different editors and IDEs
2 | # editorconfig.org
3 | root = true
4 |
5 | [*]
6 | end_of_line = lf
7 | charset = utf-8
8 | trim_trailing_whitespace = false
9 | insert_final_newline = true
10 | indent_style = tab
11 |
12 | [*.json]
13 | indent_style = space
14 | indent_size = 2
15 |
--------------------------------------------------------------------------------
/.eslintignore:
--------------------------------------------------------------------------------
1 | .publish/*
2 | dist/*
3 | example/dist/*
4 | lib/*
5 | node_modules/*
6 |
--------------------------------------------------------------------------------
/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "parser": "babel-eslint",
3 | "env": {
4 | "browser": true,
5 | "node": true
6 | },
7 | "plugins": [
8 | "react"
9 | ],
10 | "rules": {
11 | "curly": [2, "multi-line"],
12 | "quotes": [2, "single", "avoid-escape"],
13 | "react/display-name": 0,
14 | "react/jsx-boolean-value": 1,
15 | "react/jsx-quotes": 1,
16 | "react/jsx-no-undef": 1,
17 | "react/jsx-sort-props": 0,
18 | "react/jsx-sort-prop-types": 1,
19 | "react/jsx-uses-react": 1,
20 | "react/jsx-uses-vars": 1,
21 | "react/no-did-mount-set-state": 1,
22 | "react/no-did-update-set-state": 1,
23 | "react/no-multi-comp": 0,
24 | "react/no-unknown-property": 1,
25 | "react/prop-types": 1,
26 | "react/react-in-jsx-scope": 1,
27 | "react/self-closing-comp": 1,
28 | "react/wrap-multilines": 1,
29 | "semi": 2,
30 | "strict": 0
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 |
5 | # Runtime data
6 | pids
7 | *.pid
8 | *.seed
9 |
10 | # Coverage tools
11 | lib-cov
12 | coverage
13 | coverage.html
14 | .cover*
15 |
16 | # Dependency directory
17 | node_modules
18 |
19 | # Example build directory
20 | example/dist
21 | .publish
22 |
23 | # Editor and other tmp files
24 | *.swp
25 | *.un~
26 | *.iml
27 | *.ipr
28 | *.iws
29 | *.sublime-*
30 | .idea/
31 | *.DS_Store
32 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | ## CHANGELOG
2 |
3 | ### 0.1.0
4 |
5 | * [BREAKING CHANGE] React 0.13 => React 0.14
6 | * The dependency allows the lib to use parent-based context
7 | * [FEATURE] `reverse` prop for flipping the side of the avatar
8 |
9 | ### 0.0.8
10 |
11 | * [FIX] remove `.isRequired` from `Img` href PropType
12 |
13 | ### 0.0.7
14 |
15 | * [BREAKING CHANGE] Remove default Media styles `margin: 0 1.5em`
16 |
17 | ### 0.0.6
18 |
19 | * [FEATURE] add noDefaultStyle prop for clearing default styles
20 | * [FEATURE] extract styleResolver into reusable function
21 |
22 | ### 0.0.5
23 |
24 | * [BREAKING CHANGE] remove default classes
25 | + media
26 | + img
27 | + bd
28 | * [BREAKING CHANGE] merge props.style into default style. no longer wipes out default style
29 | * [FEATURE] add tests via `npm test` and `npm run test:watch`
30 |
31 | ### 0.0.4
32 |
33 | * [BREAKING CHANGE] remove namspacing
34 | + MediaImg -> Img
35 | + MediaImgExt -> ImgExt
36 | + MediaBd -> Bd
37 |
38 | ### <0.0.4
39 |
40 | * ...stuff happened...
41 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # React Media Object
2 |
3 | This is a Media Object implementation in React.js.
4 |
5 | The CSS [Media Object](http://www.stubbornella.org/content/2010/06/25/the-media-object-saves-hundreds-of-lines-of-code/) was created by [Nicole Sullivan](https://twitter.com/stubbornella). It's an undeniably concise nugget of CSS. I love it.
6 |
7 | This project is part of a proof-of-concept for React inline-styles. In practice, can a Media Object component be as usefel and flexible as the original OOCSS version.
8 |
9 |
10 | ## Installation
11 |
12 | #### Node
13 |
14 | ```bash
15 | npm install react-media-object --save
16 | ```
17 |
18 | #### In-browser
19 |
20 | ```html
21 |
22 | ```
23 |
24 | *`React` must be available as a global when this script is run.*
25 |
26 |
27 | ## Usage
28 |
29 | ReactMediaObject is four components, half of which are optional
30 |
31 | ```html
32 | var { Media, Img, ImgExt, Bd } = require('react-media-object');
33 |
34 | var MediaObjectWithAllRegions = (
35 |
36 |
37 |
38 |
39 |
40 |
41 | I've spent most of my career focused on taming styles in CSS. I saw it as a
42 | problem that would never be solved. Then, #reactjs happened.
43 |
44 |
45 | );
46 |
47 | var MediaObjectWithMinimalRegions = (
48 |
49 |
50 | I've spent most of my career focused on taming styles in CSS. I saw it as a
51 | problem that would never be solved. Then, #reactjs happened.
52 |
53 |
54 | );
55 |
56 | ReactDOM.render(MediaObjectWithAllRegions, mountNode);
57 | ```
58 |
59 |
60 | ## Development
61 |
62 | To build the examples locally, clone and run:
63 |
64 | ```bash
65 | npm install
66 | npm start
67 | ```
68 |
69 | Then open [`localhost:8000`](http://localhost:8000) in a browser.
70 |
71 |
72 | #### Structure
73 |
74 | **NOTE:** The source code for the component is in `src`. A transpiled CommonJS version (generated with Babel) is available in `lib` for use with node.js, browserify and webpack. A UMD bundle is also built to `dist`, which can be included without the need for any build system.
75 |
76 | To build, watch and serve the examples (which will also watch the component source), run `npm start`. If you just want to watch changes to `src` and rebuild `lib`, run `npm run watch` (this is useful if you are working with `npm link`).
77 |
78 | ## License
79 |
80 | The MIT License (MIT)
81 |
82 | Copyright (c) 2015 Michael Chan
83 |
84 | Permission is hereby granted, free of charge, to any person obtaining a copy
85 | of this software and associated documentation files (the "Software"), to deal
86 | in the Software without restriction, including without limitation the rights
87 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
88 | copies of the Software, and to permit persons to whom the Software is
89 | furnished to do so, subject to the following conditions:
90 |
91 | The above copyright notice and this permission notice shall be included in
92 | all copies or substantial portions of the Software.
93 |
94 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
95 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
96 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
97 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
98 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
99 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
100 | THE SOFTWARE.
101 |
--------------------------------------------------------------------------------
/bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "react-media-object",
3 | "version": "0.1.0",
4 | "description": "A React.js Media-Object",
5 | "main": "dist/react-media-object.min.js",
6 | "homepage": "https://github.com/chantastic/react-media-object",
7 | "authors": [
8 | "Michael Chan"
9 | ],
10 | "keywords": [
11 | "react",
12 | "react-component",
13 | "media-object"
14 | ],
15 | "license": "MIT",
16 | "ignore": [
17 | ".editorconfig",
18 | ".gitignore",
19 | "package.json",
20 | "src",
21 | "node_modules",
22 | "example",
23 | "test",
24 | "**/.*",
25 | "bower_components",
26 | "tests"
27 | ]
28 | }
29 |
--------------------------------------------------------------------------------
/dist/react-media-object.js:
--------------------------------------------------------------------------------
1 | (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.ReactMediaObject = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o
9 |
10 |
With optional regions
11 |
12 |
13 |
14 |
17 |
18 |
19 |
20 | I've spent most of my career focused on taming styles in CSS. I
21 | saw it as a problem that would never be solved. Then, #reactjs
22 | happened.
23 |
35 |
36 |
37 |
40 |
41 |
42 |
43 | I've spent most of my career focused on taming styles in CSS. I
44 | saw it as a problem that would never be solved. Then, #reactjs
45 | happened.
46 |
58 |
59 |
60 | chantastic
61 |
62 |
63 | I've spent most of my career focused on taming styles in CSS. I
64 | saw it as a problem that would never be solved. Then, #reactjs
65 | happened.
66 |
81 | I've spent most of my career focused on taming styles in CSS. I
82 | saw it as a problem that would never be solved. Then, #reactjs
83 | happened.
84 | @chantastic
85 | 7 hours ago
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
Overriding inline-styles
94 |
95 |
96 |
97 |
102 |
103 |
104 |
105 | I've spent most of my career focused on taming styles in CSS. I
106 | saw it as a problem that would never be solved. Then, #reactjs
107 | happened.
108 |
129 | I've spent most of my career focused on taming styles in CSS. I
130 | saw it as a problem that would never be solved. Then, #reactjs
131 | happened.
132 | @chantastic
133 | 7 hours ago
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
noDefaultStyle prop
142 |
143 |
144 |
145 |
149 |
150 |
151 | I've spent most of my career focused on taming styles in CSS. I
152 | saw it as a problem that would never be solved. Then, #reactjs
153 | happened.
154 | @chantastic
155 | 7 hours ago
156 |
157 |
158 |