├── .editorconfig
├── .eslintignore
├── .eslintrc-base
├── .eslintrc-node
├── .eslintrc-react
├── .eslintrc-react-test
├── .gitignore
├── .npmignore
├── .travis.yml
├── CONTRIBUTING.md
├── DEVELOPMENT.md
├── LICENSE.txt
├── README.md
├── demo
├── app.css
├── app.jsx
├── components
│ ├── book.jsx
│ ├── class-based-layout.jsx
│ ├── column-based-layout.jsx
│ └── style-based-layout.jsx
├── images
│ ├── ChapterhouseDune.jpg
│ ├── ChildrenOfDune.jpg
│ ├── Dune.jpg
│ ├── DuneMessiah.jpg
│ ├── GodEmperorOfDune.jpg
│ └── HereticsOfDune.jpg
├── index.html
├── webpack.config.dev.js
└── webpack.config.hot.js
├── dist
├── boilerplate-component.js
├── boilerplate-component.js.map
├── boilerplate-component.min.js
└── boilerplate-component.min.js.map
├── karma.conf.coverage.js
├── karma.conf.dev.js
├── karma.conf.js
├── package.json
├── src
├── components
│ ├── container-query-columns.jsx
│ └── container-query.jsx
└── index.js
├── test
└── client
│ ├── main.js
│ ├── spec
│ └── components
│ │ ├── container-query-columns.spec.jsx
│ │ └── container-query.spec.jsx
│ └── test.html
├── webpack.config.coverage.js
├── webpack.config.dev.js
├── webpack.config.js
└── webpack.config.test.js
/.editorconfig:
--------------------------------------------------------------------------------
1 | # editorconfig.org
2 | root = true
3 |
4 | [*]
5 | indent_style = space
6 | indent_size = 2
7 | end_of_line = lf
8 | charset = utf-8
9 | trim_trailing_whitespace = true
10 | insert_final_newline = true
11 | max_line_length = 100
12 |
13 | [*.md]
14 | trim_trailing_whitespace = false
--------------------------------------------------------------------------------
/.eslintignore:
--------------------------------------------------------------------------------
1 | dist/*
2 | node_modules/*
3 |
--------------------------------------------------------------------------------
/.eslintrc-base:
--------------------------------------------------------------------------------
1 | ---
2 | plugins:
3 | - "filenames"
4 |
5 | rules:
6 | "filenames/filenames": [2, "^[a-z0-9\\-\\.]+$"] # dash-cased filenames.
7 |
--------------------------------------------------------------------------------
/.eslintrc-node:
--------------------------------------------------------------------------------
1 | ---
2 | extends:
3 | - "defaults/configurations/walmart/es5-node"
4 | - ".eslintrc-base"
5 |
--------------------------------------------------------------------------------
/.eslintrc-react:
--------------------------------------------------------------------------------
1 | ---
2 | extends:
3 | - "defaults/configurations/walmart/es6-react"
4 | - ".eslintrc-base"
5 |
--------------------------------------------------------------------------------
/.eslintrc-react-test:
--------------------------------------------------------------------------------
1 | ---
2 | extends:
3 | - "defaults/configurations/walmart/es6-react"
4 | - "defaults/environments/test"
5 | - ".eslintrc-base"
6 |
7 | globals:
8 | expect: false
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ### SublimeText ###
2 | *.sublime-workspace
3 |
4 | ### OSX ###
5 | .DS_Store
6 | .AppleDouble
7 | .LSOverride
8 | Icon
9 |
10 | # Thumbnails
11 | ._*
12 |
13 | # Files that might appear on external disk
14 | .Spotlight-V100
15 | .Trashes
16 |
17 | ### Windows ###
18 | # Windows image file caches
19 | Thumbs.db
20 | ehthumbs.db
21 |
22 | # Folder config file
23 | Desktop.ini
24 |
25 | # Recycle Bin used on file shares
26 | $RECYCLE.BIN/
27 |
28 | # App specific
29 |
30 | coverage
31 | node_modules
32 | bower_components
33 | .tmp
34 | lib
35 | npm-debug.log
36 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | # Cruft
2 | *.sublime-workspace
3 | .DS_Store
4 | .AppleDouble
5 | .LSOverride
6 | Icon
7 | ._*
8 | .Spotlight-V100
9 | .Trashes
10 | Thumbs.db
11 | ehthumbs.db
12 | Desktop.ini
13 | $RECYCLE.BIN/
14 | .tmp
15 | npm-debug.log
16 |
17 | # Code / build
18 | coverage
19 | node_modules
20 | bower_components
21 | demo
22 | test
23 | karma*
24 | webpack*
25 | .eslint*
26 | .editor*
27 | .travis*
28 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 |
3 | node_js:
4 | - 0.10
5 | - 0.12
6 |
7 | # Use container-based Travis infrastructure.
8 | sudo: false
9 |
10 | branches:
11 | only:
12 | - master
13 |
14 | before_install:
15 | # GUI for real browsers.
16 | - export DISPLAY=:99.0
17 | - sh -e /etc/init.d/xvfb start
18 |
19 | script:
20 | - npm run check-ci
21 |
22 | # Prune deps to just production and ensure we can still build
23 | - npm prune --production
24 | - npm install --production
25 | - npm run build
26 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | Contributing
2 | ============
3 |
4 | Thanks for helping out!
5 |
6 | ## Development
7 |
8 | Run `npm run dev` to run a webpack dev server with component examples.
9 |
10 | ## Checks, Tests
11 |
12 | Run `npm run check` before committing.
13 |
14 | ## Dist
15 |
16 | Please do not commit changes to files in `dist`.
17 | These files are only committed when we tag releases.
18 |
--------------------------------------------------------------------------------
/DEVELOPMENT.md:
--------------------------------------------------------------------------------
1 | Development
2 | ===========
3 |
4 | ## Build
5 |
6 | Build for production use (NPM, bower, etc) and create `dist` UMD bundles
7 | (min'ed, non-min'ed)
8 |
9 | ```
10 | $ npm run build
11 | ```
12 |
13 | Note that `dist/` files are only updated and committed on **tagged releases**.
14 |
15 |
16 | ## Development
17 |
18 | All development tasks consist of watching the demo bundle, the test bundle
19 | and launching a browser pointed to the demo page.
20 |
21 | Run the `demo` application with watched rebuilds:
22 |
23 | ```
24 | $ npm run dev # dev test/app server (OR)
25 | $ npm run open-dev # dev servers _and a browser window opens!_
26 | ```
27 |
28 | From there you can see:
29 |
30 | * Demo app: [127.0.0.1:3000](http://127.0.0.1:3000/)
31 | * Client tests: [127.0.0.1:3001/test/client/test.html](http://127.0.0.1:3001/test/client/test.html)
32 |
33 |
34 | ## Programming Guide
35 |
36 | ### Logging
37 |
38 | We use the following basic pattern for logging:
39 |
40 | ```js
41 | if (process.env.NODE_ENV !== "production") {
42 | /* eslint-disable no-console */
43 | if (typeof console !== "undefined" && console.warn) {
44 | console.warn("Oh noes! bad things happened.");
45 | }
46 | /* eslint-enable no-console */
47 | }
48 | ```
49 |
50 | Replace `console.warn` in the condtional + method call as appropriate.
51 |
52 | Breaking this down:
53 |
54 | * `process.env.NODE_ENV !== "production"` - This part removes all traces of
55 | the code in the production bundle, to save on file size. This _also_ means
56 | that no warnings will be displayed in production.
57 | * `typeof console !== "undefined" && console.METHOD` - A permissive check to
58 | make sure the `console` object exists and can use the appropriate `METHOD` -
59 | `warn`, `info`, etc.
60 |
61 | To signal production mode to the webpack build, declare the `NODE_ENV` variable:
62 |
63 | ```js
64 | new webpack.DefinePlugin({
65 | "process.env.NODE_ENV": JSON.stringify("production")
66 | })
67 | ```
68 |
69 | Unfortunately, we need to do _all_ of this every time to have Uglify properly
70 | drop the code, but with this trick, the production bundle has no change in code
71 | size.
72 |
73 |
74 | ## Quality
75 |
76 | ### In Development
77 |
78 | During development, you are expected to be running either:
79 |
80 | ```
81 | $ npm run dev
82 | ```
83 |
84 | to build the lib and test files. With these running, you can run the faster
85 |
86 | ```
87 | $ npm run check-dev
88 | ```
89 |
90 | Command. It is comprised of:
91 |
92 | ```
93 | $ npm run lint
94 | $ npm run test-dev
95 | ```
96 |
97 | Note that the tests here are not instrumented for code coverage and are thus
98 | more development / debugging friendly.
99 |
100 | ### Continuous Integration
101 |
102 | CI doesn't have source / test file watchers, so has to _build_ the test files
103 | via the commands:
104 |
105 | ```
106 | $ npm run check # PhantomJS only
107 | $ npm run check-cov # (OR) PhantomJS w/ coverage
108 | $ npm run check-ci # (OR) PhantomJS,Firefox + coverage - available on Travis.
109 | ```
110 |
111 | Which is currently comprised of:
112 |
113 | ```
114 | $ npm run lint # AND ...
115 |
116 | $ npm run test # PhantomJS only
117 | $ npm run test-cov # (OR) PhantomJS w/ coverage
118 | $ npm run test-ci # (OR) PhantomJS,Firefox + coverage
119 | ```
120 |
121 | Note that `(test|check)-(cov|ci)` run code coverage and thus the
122 | test code may be harder to debug because it is instrumented.
123 |
124 | ### Client Tests
125 |
126 | The client tests rely on webpack dev server to create and serve the bundle
127 | of the app/test code at: http://127.0.0.1:3001/assets/main.js which is done
128 | with the task `npm run server-test` (part of `npm dev`).
129 |
130 | #### Code Coverage
131 |
132 | Code coverage reports are outputted to:
133 |
134 | ```
135 | coverage/
136 | client/
137 | BROWSER_STRING/
138 | lcov-report/index.html # Viewable web report.
139 | ```
140 |
141 | ## Releases
142 |
143 | **IMPORTANT - NPM**: To correctly run `preversion` your first step is to make
144 | sure that you have a very modern `npm` binary:
145 |
146 | ```
147 | $ npm install -g npm
148 | ```
149 |
150 | Built files in `dist/` should **not** be committeed during development or PRs.
151 | Instead we _only_ build and commit them for published, tagged releases. So
152 | the basic workflow is:
153 |
154 | ```
155 | # Make sure you have a clean, up-to-date `master`
156 | $ git pull
157 | $ git status # (should be no changes)
158 |
159 | # Choose a semantic update for the new version.
160 | # If you're unsure, read about semantic versioning at http://semver.org/
161 | $ npm version major|minor|patch -m "Version %s - INSERT_REASONS"
162 |
163 | # ... the `dist/` and `lib/` directories are now built, `package.json` is
164 | # updated, and the appropriate files are committed to git (but unpushed).
165 | #
166 | # *Note*: `lib/` is uncommitted, but built and must be present to push to npm.
167 |
168 | # Check that everything looks good in last commit and push.
169 | $ git diff HEAD^ HEAD
170 | $ git push && git push --tags
171 | # ... the project is now pushed to GitHub and available to `bower`.
172 |
173 | # And finally publish to `npm`!
174 | $ npm publish
175 | ```
176 |
177 | And you've published!
178 |
179 | For additional information on the underlying NPM technologies and approaches,
180 | please review:
181 |
182 | * [`npm version`](https://docs.npmjs.com/cli/version): Runs verification,
183 | builds `dist/` and `lib/` via `scripts` commands.
184 | * Our scripts also run the applicable `git` commands, so be very careful
185 | when running out `version` commands.
186 | * [`npm publish`](https://docs.npmjs.com/cli/publish): Uploads to NPM.
187 | * **NOTE**: We don't _build_ in `prepublish` because of the
188 | [`npm install` runs `npm prepublish` bug](https://github.com/npm/npm/issues/3059)
189 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Formidable Labs
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ***
2 | # NOTICE:
3 |
4 | ## This repository has been archived and is not supported.
5 |
6 | [](http://unmaintained.tech/)
7 | ***
8 | NOTICE: SUPPORT FOR THIS PROJECT HAS ENDED
9 |
10 | This projected was owned and maintained by Walmart. This project has reached its end of life and Walmart no longer supports this project.
11 |
12 | We will no longer be monitoring the issues for this project or reviewing pull requests. You are free to continue using this project under the license terms or forks of this project at your own risk. This project is no longer subject to Walmart's bug bounty program or other security monitoring.
13 |
14 |
15 | ## Actions you can take
16 |
17 | We recommend you take the following action:
18 |
19 | * Review any configuration files used for build automation and make appropriate updates to remove or replace this project
20 | * Notify other members of your team and/or organization of this change
21 | * Notify your security team to help you evaluate alternative options
22 |
23 | ## Forking and transition of ownership
24 |
25 | For [security reasons](https://www.theregister.co.uk/2018/11/26/npm_repo_bitcoin_stealer/), Walmart does not transfer the ownership of our primary repos on Github or other platforms to other individuals/organizations. Further, we do not transfer ownership of packages for public package management systems.
26 |
27 | If you would like to fork this package and continue development, you should choose a new name for the project and create your own packages, build automation, etc.
28 |
29 | Please review the licensing terms of this project, which continue to be in effect even after decommission.
30 |
31 | ContainerQuery
32 | ==============
33 |
34 | A common problem in responsive design is the layout being depedent on the width
35 | of the media (i.e. a media query) as opposed to the width of the host container
36 | (i.e. a container query).
37 |
38 | For example, let's say you have a book list, and you want it to be one column in
39 | a small width, then two, then four columns as the width of the content area grows.
40 | Great, if you control the entire screen. But what if the list is put into the sidebar.
41 | Now, even though the screen maybe large, the width for the book list is small.
42 |
43 | So we need a tool to be able to define breakpoints relative to the container
44 | and not to the screen.
45 |
46 | Introducing, `ContainerQuery`, where you can define breakpoint names on a container
47 | and then apply `style`, `props` or `className` depending on the current width of the
48 | container. For example:
49 |
50 | ```jsx
51 |
52 |
58 |
64 | ...
65 |
66 | ```
67 |
68 | Will check to see how much space it's given, turn that into a breakpoint name (e.g. `small`,
69 | `medium` or `large`) and then set the `className` of the children of the component
70 | based on that value.
71 |
72 | You can also set styles:
73 |
74 | ```jsx
75 |
77 |
83 |
89 |
90 | ```
91 |
92 | In this case we are setting the `width` as a `style` based on the current breakpoint
93 | as defined by the `breakpoints` object.
94 |
95 | You can also set properties:
96 |
97 | ```jsx
98 |
100 |
106 |
107 | ```
108 |
109 | If your component, in this case, knows how to interpret `size` in some meaningful way.
110 |
111 | And, of course, you can use any combination of these.
112 |
113 | You are also free to name the breakpoints however you choose.
114 |
115 | For something even easier you can use a columns-based helper class like so:
116 |
117 | ```jsx
118 |
121 |
124 |
127 |
128 | ```
129 |
130 | Which sets `width` in the `style` of all of the children using the number of columns
131 | defined in the `at-{breakpoint}` props in the `ContainerQuery.Columns` component.
132 |
133 | ## Development
134 |
135 | Please see [DEVELOPMENT](DEVELOPMENT.md)
136 |
137 | ## Contributing
138 |
139 | Please see [CONTRIBUTING](CONTRIBUTING.md)
140 |
--------------------------------------------------------------------------------
/demo/app.css:
--------------------------------------------------------------------------------
1 | body {
2 | font-family: arial, verdana, sans-serif;
3 | margin: 2em;
4 | }
5 |
6 | h4 {
7 | border-bottom: 2px solid black;
8 | }
9 |
10 | .main .left {
11 | float: left;
12 | width: 500px;
13 | }
14 |
15 | .main .right {
16 | float: left;
17 | width: 150px;
18 | }
19 |
20 | .book {
21 | float: left;
22 | text-align: center;
23 | font-weight: bold;
24 | padding: 0.5em;
25 | }
26 |
27 | .book .image img {
28 | width: 100px;
29 | }
30 |
31 | .book .title {
32 | font-size: xx-small;
33 | }
34 |
35 | .col-12 {
36 | width: 90%;
37 | }
38 | .col-6 {
39 | width: 50%;
40 | }
41 | .col-3 {
42 | width: 25%;
43 | }
44 |
--------------------------------------------------------------------------------
/demo/app.jsx:
--------------------------------------------------------------------------------
1 | /*global document:false*/
2 | import React from "react/addons";
3 |
4 | import "./app.css";
5 |
6 | import ClassBasedLayout from "./components/class-based-layout";
7 | import ColumnBasedLayout from "./components/column-based-layout";
8 | import StyleBasedLayout from "./components/style-based-layout";
9 |
10 | class App extends React.Component {
11 | render() {
12 | return (
13 |