Skip to content

Commit 7cee4a3

Browse files
Release v0.0.9 (#33)
1 parent 0d08375 commit 7cee4a3

File tree

3 files changed

+87
-34
lines changed

3 files changed

+87
-34
lines changed

CHANGELOG.md

Lines changed: 45 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,74 @@
1+
# v0.0.9
2+
3+
## Changes
4+
5+
* Reworked the approach to render the containers. It now uses an adapter that
6+
you have to configure. The adapter is used to output the actual HTML. For now,
7+
the adapter provided is the
8+
[CellJS adapter](https://github.com/DefactoSoftware/cells-js) (#30)
9+
* The CellJS adapter no longer accepts a `closing_tag` attribute as added in the
10+
previous release. The CellJS adapter no automatically closes self closing tags
11+
(#31)
12+
113
# v0.0.8
14+
215
## Changed
3-
- Use Phoenix.content_tag instead of Phoenix.tag by default and add option to remove the closing tag by adding `closing_tag: false` to the options (#27)
4-
- The attribute name is now used to set the `data-cell` attribute and can be overridden to allow prefixing (#28)
16+
17+
* Use Phoenix.content_tag instead of Phoenix.tag by default and add option to
18+
remove the closing tag by adding `closing_tag: false` to the options (#27)
19+
* The attribute name is now used to set the `data-cell` attribute and can be
20+
overridden to allow prefixing (#28)
521

622
# v0.0.7
23+
724
## Changed
8-
- Added a cell render method to ExCell.Controller to directly render cells as a view (#23)
25+
26+
* Added a cell render method to ExCell.Controller to directly render cells as a
27+
view (#23)
928

1029
## Fixed
11-
- Removed unused Base alias in `lib/ex_cell/base.ex` (#22)
30+
31+
* Removed unused Base alias in `lib/ex_cell/base.ex` (#22)
1232

1333
# v0.0.6
1434

1535
## Changed
16-
- Updated `README.md` with more elaborate examples and install instructions (#19)
17-
- Removed the need for a `MockCellAdapter` in tests (#18)
18-
- Restructured the code to allow documentation (#18)
36+
37+
* Updated `README.md` with more elaborate examples and install instructions
38+
(#19)
39+
* Removed the need for a `MockCellAdapter` in tests (#18)
40+
* Restructured the code to allow documentation (#18)
1941

2042
## Removed
21-
- The option to provide a `MockCellAdapter` in the configuration (#18)
43+
44+
* The option to provide a `MockCellAdapter` in the configuration (#18)
2245

2346
# v0.0.5
2447

2548
## Changed
26-
- Cell module didn't use a fallback adapter for the `__using__` macro (#16)
27-
- Added back the `View.relative_path` method (#15)
49+
50+
* Cell module didn't use a fallback adapter for the `__using__` macro (#16)
51+
* Added back the `View.relative_path` method (#15)
2852

2953
# v0.0.4
3054

3155
## Changed
32-
- Fixed a bug where the Mix configuration wasn't allowing empty configurations (#13)
56+
57+
* Fixed a bug where the Mix configuration wasn't allowing empty configurations
58+
(#13)
3359

3460
# v0.0.3
3561

3662
## Added
37-
- Adapters can are now in a `config.ex` (#10)
63+
64+
* Adapters can are now in a `config.ex` (#10)
3865

3966
## Changed
40-
- Removed the need to specify an adapter for views and controllers (#10)
41-
- ExCell.Controller is imported instead of using the `__using__` macro (#10)
67+
68+
* Removed the need to specify an adapter for views and controllers (#10)
69+
* ExCell.Controller is imported instead of using the `__using__` macro (#10)
4270

4371
## Removed
44-
- It's no longer possible to specify the adapter through the `__using__` Macro (#10)
72+
73+
* It's no longer possible to specify the adapter through the `__using__` Macro
74+
(#10)

README.md

Lines changed: 41 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,20 @@
22
[![CircleCI](https://circleci.com/gh/DefactoSoftware/ex_cell/tree/master.svg?style=shield)](https://circleci.com/gh/DefactoSoftware/ex_cell)
33

44
# ex_cell
5+
56
A module for creating coupled modules of CSS, Javascript and Views in Phoenix
67

78
## Installation
89

910
Add the following to the dependencies in `mix.exs`
11+
1012
```ex
11-
{:ex_cell, "~> 0.0.8"}
13+
{:ex_cell, "~> 0.0.9"}
1214
```
1315

1416
In Phoenix 1.3.0+ add the following to `lib/app_web/web.ex`:
1517

1618
```ex
17-
1819
def controller do
1920
quote do
2021
...
@@ -37,7 +38,8 @@ end
3738

3839
def cell(opts \\ []) do
3940
quote do
40-
use ExCell.Cell, namespace: AppWeb
41+
use ExCell.Cell, namespace: AppWeb,
42+
adapter: ExCell.Adapters.CellJS
4143

4244
use Phoenix.View, root: "lib/app_web/cells",
4345
path: ExCell.View.relative_path(__MODULE__AppWeb)
@@ -55,12 +57,16 @@ def cell(opts \\ []) do
5557
end
5658
```
5759

58-
Now you can add a cells/ directory in lib/app_web and place cells in that directory.
60+
Now you can add a cells/ directory in lib/app_web and place cells in that
61+
directory.
5962

60-
Every cell should contain a view.ex and a template.html.eex. The view and template are tightly linked together by the Cell.
63+
Every cell should contain a view.ex and a template.html.eex. The view and
64+
template are tightly linked together by the Cell.
6165

6266
## CSS
63-
To ensure all the CSS can be placed next to your cell you need to add the following to your `brunch-config.js`:
67+
68+
To ensure all the CSS can be placed next to your cell you need to add the
69+
following to your `brunch-config.js`:
6470

6571
```js
6672
...
@@ -75,10 +81,15 @@ stylesheets: {
7581
...
7682
```
7783

78-
If you use something other than `brunch` to manage your assets, you need to add the files to the assets manager of choice.
84+
If you use something other than `brunch` to manage your assets, you need to add
85+
the files to the assets manager of choice.
7986

8087
## Javascript
81-
If you wish to use the accompanying `cell-js` library you can install [cell-js](https://github.com/DefactoSoftware/cells-js) with your package manager. After you installed the Javascript package, add the following to your `brunch-config.js`:
88+
89+
If you wish to use the accompanying `cell-js` library you can install
90+
[cell-js](https://github.com/DefactoSoftware/cells-js) with your package
91+
manager. After you installed the Javascript package, add the following to your
92+
`brunch-config.js`:
8293

8394
```js
8495
...
@@ -94,9 +105,10 @@ javascripts: {
94105
...
95106
```
96107

97-
98108
## Usage
109+
99110
A cell consists of a couple of files:
111+
100112
```
101113
cells
102114
|- avatar
@@ -108,7 +120,9 @@ cells
108120
...
109121
```
110122

111-
You can render the cell in a view, controller or another cell by adding the following code:
123+
You can render the cell in a view, controller or another cell by adding the
124+
following code:
125+
112126
```ex
113127
cell(AvatarCell, class: "CustomClassName", user: %User{})
114128
```
@@ -121,10 +135,12 @@ This would generate the following HTML when you render the cell:
121135
</span>
122136
```
123137

124-
125138
### view.ex
126139

127-
Views of cells behave like normal views in Phoenix, except that they have provide a container method that can be used in a template to render the appropiate HTML needed to initialize the Javascript for a cell and have a predefined class that is the same as the cell name minus the namespace.
140+
Views of cells behave like normal views in Phoenix, except that they have
141+
provide a container method that can be used in a template to render the
142+
appropiate HTML needed to initialize the Javascript for a cell and have a
143+
predefined class that is the same as the cell name minus the namespace.
128144

129145
```ex
130146
# lib/app_web/cell/avatar/view.ex
@@ -154,7 +170,9 @@ end
154170
```
155171

156172
### template.html.eex
157-
The template behave like any other template in Phoenix except that they have access to a container method to render the appropiate cell HTML container:
173+
174+
The template behave like any other template in Phoenix except that they have
175+
access to a container method to render the appropiate cell HTML container:
158176

159177
```eex
160178
<!-- lib/app_web/cell/avatar/template.html.eex -->
@@ -166,7 +184,11 @@ The template behave like any other template in Phoenix except that they have acc
166184
```
167185

168186
### style.css
169-
This can be any type of CSS file that you wish (preprocessed or other wise). Because cells provides methods to namespace your CSS you are advised to use a similar namespace or use something like `postcss-modules` to ensure all classses defined are unique.
187+
188+
This can be any type of CSS file that you wish (preprocessed or other wise).
189+
Because cells provides methods to namespace your CSS you are advised to use a
190+
similar namespace or use something like `postcss-modules` to ensure all classses
191+
defined are unique.
170192

171193
```css
172194
.AvatarCell {
@@ -182,18 +204,19 @@ This can be any type of CSS file that you wish (preprocessed or other wise). Bec
182204
```
183205

184206
### index.js
185-
If you use `cells-js` you can create Javascript that is tightly coupled to the cell.
207+
208+
If you use `cells-js` you can create Javascript that is tightly coupled to the
209+
cell.
186210

187211
```js
188212
import { Cell, Builder } from "cells-js";
189213

190214
class AvatarCell extends Cell {
191215
initialize() {
192-
this.element.addEventListener('click', this.onToggleOpenClass)
193-
216+
this.element.addEventListener("click", this.onToggleOpenClass);
194217
}
195218

196-
onToggleOpenClass = (e)=> this.element.classList.toggle("open");
219+
onToggleOpenClass = e => this.element.classList.toggle("open");
197220
}
198221

199222
Builder.register(AvatarCell, "AvatarCell");

mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
defmodule ExCell.Mixfile do
22
use Mix.Project
33

4-
@version "0.0.8"
4+
@version "0.0.9"
55

66
def project do
77
[app: :ex_cell,

0 commit comments

Comments
 (0)