shimmer 0.0.29 → 0.0.31

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e77dab032d0ec3a48d22321c020868645d0a6d8649821518189decd58ebffb0f
4
- data.tar.gz: 1a6957d6dea3f04288166eaf4a7cbb011ebfdd9b26bb2675f0b1faaffa7eda3f
3
+ metadata.gz: 779d79fb4df76a9a95f859cc5e5d0f42972518abd03a52e99f650258c2a309d1
4
+ data.tar.gz: d48baefb78dc663222646bd7cc98c6e6d15b2f8d76546e4f906fdd45aa61bab3
5
5
  SHA512:
6
- metadata.gz: 0a479f55de54862deb63928a2be5f58ccd3b142b059db16e4405c958f527758e348bbd1d82147646705492aa7d28ea2702549075de34522900d1eda83c5d0802
7
- data.tar.gz: 6c493df14ce2242f4e735d04a2a5e398ae3cf1cb8c2d7d081a8061be6f08d0d552627d85753f542a97a4075a7acfb58c0bfa64bd5c708c4ca0344793ff047602
6
+ metadata.gz: 61ff05bdd88fd025936e51e3fef3847c9f7ef2141279e14bc508ae794e7bf149f81169835272504d8c8f7b93ccf459a0c4ce46c087ce4e0528e465c1870fe83a
7
+ data.tar.gz: 502f044707bf5049a79f8af12ee82d3a5aed421522085f761c5564318d96fdccc2c14ee63056b2b1ef948ad02a685c0db18e7cb09e420e8ba311926fb2bead70
data/.babelrc ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "presets": [
3
+ "@babel/preset-env",
4
+ "@babel/preset-react",
5
+ "@babel/preset-flow"
6
+ ],
7
+ "plugins": [
8
+ "@babel/plugin-proposal-class-properties",
9
+ "babel-plugin-inline-json-import",
10
+ ["@babel/plugin-transform-runtime", {
11
+ "regenerator": true
12
+ }]
13
+ ]
14
+ }
data/Gemfile CHANGED
@@ -19,6 +19,8 @@ gem "dotenv"
19
19
  gem "slim-rails"
20
20
  gem "awesome_print"
21
21
  gem "dotenv-rails"
22
+ gem "image_processing"
23
+ gem "mini_magick"
22
24
 
23
25
  group :development, :test do
24
26
  gem "debug", platforms: [:mri, :mingw, :x64_mingw]
data/Gemfile.lock CHANGED
@@ -135,6 +135,9 @@ GEM
135
135
  rspec (>= 2.99.0, < 4.0)
136
136
  i18n (1.12.0)
137
137
  concurrent-ruby (~> 1.0)
138
+ image_processing (1.12.2)
139
+ mini_magick (>= 4.9.5, < 5)
140
+ ruby-vips (>= 2.0.17, < 3)
138
141
  io-console (0.6.0)
139
142
  irb (1.6.2)
140
143
  reline (>= 0.3.0)
@@ -161,6 +164,7 @@ GEM
161
164
  marcel (1.0.2)
162
165
  matrix (0.4.2)
163
166
  method_source (1.0.0)
167
+ mini_magick (4.12.0)
164
168
  mini_mime (1.1.2)
165
169
  minitest (5.17.0)
166
170
  msgpack (1.6.0)
@@ -294,6 +298,8 @@ GEM
294
298
  rubocop (~> 1.33)
295
299
  rubocop-capybara (~> 2.17)
296
300
  ruby-progressbar (1.13.0)
301
+ ruby-vips (2.1.4)
302
+ ffi (~> 1.12)
297
303
  shellany (0.0.1)
298
304
  slim (4.1.0)
299
305
  temple (>= 0.7.6, < 0.9)
@@ -356,8 +362,10 @@ DEPENDENCIES
356
362
  dotenv-rails
357
363
  guard
358
364
  guard-rspec
365
+ image_processing
359
366
  jbuilder
360
367
  jsbundling-rails
368
+ mini_magick
361
369
  propshaft
362
370
  pry
363
371
  pry-byebug
@@ -383,4 +391,4 @@ DEPENDENCIES
383
391
  web-console
384
392
 
385
393
  BUNDLED WITH
386
- 2.3.26
394
+ 2.4.9
data/README.md CHANGED
@@ -4,20 +4,137 @@ Shimmer is a collection of Rails extensions that bring advanced UI features into
4
4
 
5
5
  ## Features
6
6
 
7
+ ### Components
8
+
9
+ Shimmer includes a suite of styled components that can be implemented in React and also in plain HTML or slim.
10
+
11
+ ### Stack
12
+
13
+ Stack is a reusable typed component that allows you to easily manage the layout of your app. You can define whether it should be displayed horizontally, vertically, and how much spacing there should be in between the child components. This component implements a mobile-first design and allows you to customize the display and spacing even on defined breakpoints (tablet, desktop, widescreen) should you need to.
14
+
15
+ To use it in a React project, you can just import and use it as you would in a normal React component:
16
+
17
+ ```js
18
+ import { Stack } from "@nerdgeschoss/shimmer/components/stack";
19
+
20
+ <Stack gapTablet={4} gapDesktop={12} line>
21
+ <div></div>
22
+ <div></div>
23
+ <div></div>
24
+ </Stack>;
25
+ ```
26
+
27
+ To use it in an HTML file, you can just import the css file directly from `@nerdgeschoss/shimmer/components/stack.css` and just implement the classes as they are in the stylesheet:
28
+
29
+ ```html
30
+ <div class="stack stack--line stack--tablet-4 stack--desktop-12">
31
+ <div></div>
32
+ <div></div>
33
+ <div></div>
34
+ </div>
35
+ ```
36
+
37
+ #### Helper types:
38
+
39
+ ```ts
40
+ type Justify =
41
+ | "start"
42
+ | "center"
43
+ | "end"
44
+ | "space-between"
45
+ | "space-around"
46
+ | "stretch"
47
+ | "equal-size";
48
+ ```
49
+
50
+ ```ts
51
+ type Align = "start" | "center" | "end" | "stretch" | "baseline";
52
+ ```
53
+
54
+ ![Stack possible layouts](stack.png)
55
+
56
+ ### Available props:
57
+
58
+ | Field | Type | Description |
59
+ | ----------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
60
+ | gap | `number` | Space between elements |
61
+ | gapTablet | `number` | Gap size for screen starting on Tablet breakpoint |
62
+ | gapDesktop | `number` | Gap size for screen starting on Desktop breakpoint |
63
+ | gapWidescreen | `number` | Gap size for screen starting on WideScreen breakpoint |
64
+ | line | `boolean` | Stacks elements horizontally |
65
+ | lineTablet | `boolean` | Stacks elements horizontally starting on Tablet breakpoint |
66
+ | lineDesktop | `boolean` | Stacks elements horizontally starting on Desktop breakpoint |
67
+ | lineWidescreen | `boolean` | Stacks elements horizontally starting on WideScreen breakpoint |
68
+ | align | `Align` | Aligns element according to the [main axis](https://developer.mozilla.org/en-US/docs/Glossary/Main_Axis) of the flex container |
69
+ | alignTablet | `Align` | Align on Tablet breakpoint |
70
+ | alignDesktop | `Align` | Align on Desktop breakpoint |
71
+ | alignWidescreen | `Align` | Align on Widescreen breakpoint |
72
+ | justify | `Justify` | Specifies how elements are distributed along [main axis](https://developer.mozilla.org/en-US/docs/Glossary/Main_Axis) of the flex container |
73
+ | justifyTablet | `Justify` | Justify on Tablet breakpoint |
74
+ | justifyDesktop | `Justify` | Justify on Desktop breakpoint |
75
+ | justifyWidescreen | `Justify` | Justify on Widescreen breakpoint |
76
+
77
+ When using the CSS classes instead of react component we can generate the class names looking at the available props by using the prop names and BEM convention.
78
+
79
+ For example:
80
+
81
+ ```js
82
+ <Stack gapTablet={4} gapDesktop={12} line>
83
+ ...
84
+ </Stack>
85
+ ```
86
+
87
+ would translate to
88
+
89
+ ```html
90
+ <div class="stack stack--tablet-4 stack--destop-12 stack--line">...</div>
91
+ ```
92
+
93
+ Pleae, note that there is not word "gap" in the class names since we use it implicitly, i.e. `gapWidescreen={12}` is equivalent to `stack stack--widescreen-12`.
94
+
95
+ Another thing to keep in mind when using CSS version of the component that the sizes are fixed - in contrary to the React one where we can add any number we want.
96
+
97
+ Here is the list of available sizes for CSS version:
98
+
99
+ ```scss
100
+ $sizes: (
101
+ 0: 0px,
102
+ 2: 2px,
103
+ 4: 4px,
104
+ 8: 8px,
105
+ 12: 12px,
106
+ 16: 16px,
107
+ 20: 20px,
108
+ 22: 22px,
109
+ 24: 24px,
110
+ 32: 32px,
111
+ 40: 40px,
112
+ 48: 48px,
113
+ 56: 56px,
114
+ 64: 64px,
115
+ );
116
+ ```
117
+
118
+ ### Supported breakpoints:
119
+
120
+ - **Tablet**: 640px
121
+ - **Desktop**: 890px
122
+ - **Widescreen**: 1280px
123
+
7
124
  ### Rubocop Base Configuration
8
125
 
9
- *Shimmer* offers an opiniated *Rubocop* base configuration. This configuration inherits itself from *StandardRB* and aim at remaining as close to it as possible. Why not only use *StandardRB*, since it is so fast and prevent bikeshedding? Well, sadly, it does not solve all problems and using *Rubocop* still integrates a lot easier in most toolsets. However, the idea is to still prevent bikeshedding our *Rubocop* configuration by making sure that every exception to what's configured in *StandardRB* is justified (with a comment over its configuration block in `./config/rubocop_base.yml`), reviewed, debated, and agreed upon before being merged.
126
+ _Shimmer_ offers an opiniated _Rubocop_ base configuration. This configuration inherits itself from _StandardRB_ and aim at remaining as close to it as possible. Why not only use _StandardRB_, since it is so fast and prevent bikeshedding? Well, sadly, it does not solve all problems and using _Rubocop_ still integrates a lot easier in most toolsets. However, the idea is to still prevent bikeshedding our _Rubocop_ configuration by making sure that every exception to what's configured in _StandardRB_ is justified (with a comment over its configuration block in `./config/rubocop_base.yml`), reviewed, debated, and agreed upon before being merged.
10
127
 
11
128
  #### Use Shared Configuration In Projects
12
129
 
13
- Typically, a `.rubocop.yml` file in projects using *Shimmer* looks like this.
130
+ Typically, a `.rubocop.yml` file in projects using _Shimmer_ looks like this.
14
131
 
15
132
  ```yml
16
133
  inherit_gem:
17
134
  shimmer: config/rubocop_base.yml
18
135
  ```
19
136
 
20
- Then, if there are specific cops you want to use in the specific project you are working on, you still can easily add them. But at least, the base configuration is shared between projects and is itself as close to *StandardRB* as possible.
137
+ Then, if there are specific cops you want to use in the specific project you are working on, you still can easily add them. But at least, the base configuration is shared between projects and is itself as close to _StandardRB_ as possible.
21
138
 
22
139
  ### Static File Serving
23
140
 
@@ -4,11 +4,6 @@ require:
4
4
  RSpec:
5
5
  Enabled: false
6
6
 
7
- # Check that instances are not being stubbed globally.
8
- # Prefer instance doubles over stubbing any instance of a class.
9
- RSpec/AnyInstance:
10
- Enabled: true
11
-
12
7
  # Checks that around blocks actually run the test.
13
8
  # Would be a shame if the test would be green simply because it is not called.
14
9
  RSpec/AroundBlock:
@@ -19,6 +19,8 @@ gem "dotenv"
19
19
  gem "slim-rails"
20
20
  gem "awesome_print"
21
21
  gem "dotenv-rails"
22
+ gem "image_processing"
23
+ gem "mini_magick"
22
24
 
23
25
  group :development, :test do
24
26
  gem "debug", platforms: %i[mri mingw x64_mingw]
@@ -4,7 +4,9 @@ module Shimmer
4
4
  class SitemapsController < ActionController::Base
5
5
  def show
6
6
  path = "sitemaps/#{params.require(:path)}.gz"
7
- send_data ActiveStorage::Blob.service.download(path)
7
+ filename = "sitemap_#{params[:path]}.xml.gz"
8
+
9
+ send_data ActiveStorage::Blob.service.download(path), filename: filename, type: "application/gzip", disposition: "attachment"
8
10
  end
9
11
  end
10
12
  end
@@ -20,7 +20,7 @@ module Shimmer
20
20
  width = options[:width]
21
21
  height = options[:height]
22
22
  source = image_file_path(source, width: width, height: height)
23
- options[:loading] = :lazy
23
+ options[:loading] ||= :lazy
24
24
  options[:srcset] = "#{source} 1x, #{image_file_path(attachment, width: width.to_i * 2, height: height ? height.to_i * 2 : nil)} 2x" if options[:width].present?
25
25
  end
26
26
  super source, options
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Shimmer
4
- VERSION = "0.0.29"
4
+ VERSION = "0.0.31"
5
5
  end
data/package.json CHANGED
@@ -4,13 +4,14 @@
4
4
  "description": "Simple application development in Rails",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
7
- "types": "dist/index",
7
+ "types": "dist/index.d.ts",
8
8
  "files": [
9
9
  "dist"
10
10
  ],
11
11
  "scripts": {
12
- "build": "yarn build:js && yarn build:types",
12
+ "build": "yarn build:js && yarn build:components && yarn build:types",
13
13
  "build:js": "NODE_ENV=production rollup -c",
14
+ "build:components": "NODE_ENV=production rollup --config rollup.component.config.js && echo 'import \"./stack.css\";' >> dist/components/stack.js",
14
15
  "build:types": "tsc --emitDeclarationOnly",
15
16
  "format": "prettier --write \"src/**/*.{ts,css,scss,json,yml}\"",
16
17
  "lint": "yarn lint:types && yarn lint:style",
@@ -18,7 +19,8 @@
18
19
  "lint:style": "eslint src/**/*.ts --max-warnings 0"
19
20
  },
20
21
  "contributors": [
21
- "Jens Ravens"
22
+ "Jens Ravens",
23
+ "Geraldine Atayan"
22
24
  ],
23
25
  "license": "MIT",
24
26
  "dependencies": {
@@ -27,17 +29,35 @@
27
29
  "@rails/request.js": "^0.0.6"
28
30
  },
29
31
  "devDependencies": {
32
+ "@babel/core": "^7.0.0-0",
33
+ "@babel/plugin-proposal-class-properties": "^7.16.7",
34
+ "@babel/plugin-transform-runtime": "^7.17.0",
35
+ "@babel/preset-env": "^7.16.11",
36
+ "@babel/preset-flow": "^7.16.7",
37
+ "@babel/preset-react": "^7.16.7",
38
+ "@types/react": "^17.0.37",
39
+ "@types/react-dom": "^17.0.1",
30
40
  "@typescript-eslint/eslint-plugin": "^5.6.0",
31
41
  "@typescript-eslint/parser": "^5.6.0",
32
42
  "esbuild": "^0.14.2",
33
43
  "eslint": "^8.4.1",
34
44
  "eslint-config-prettier": "^8.3.0",
35
45
  "eslint-plugin-prettier": "^4.0.0",
46
+ "postcss": "^8.4.24",
47
+ "postcss-preset-env": "^8.5.1",
36
48
  "prettier": "^2.5.1",
37
49
  "rollup": "^2.61.0",
38
50
  "rollup-plugin-cleaner": "^1.0.0",
39
51
  "rollup-plugin-esbuild": "^4.7.2",
40
- "typescript": "^4.1.3"
52
+ "rollup-plugin-postcss": "^4.0.2",
53
+ "sass": "^1.63.4",
54
+ "typescript": "^4.1.3",
55
+ "classnames": "^2.3.2"
56
+ },
57
+ "peerDependencies": {
58
+ "react": "^17.0.1",
59
+ "react-dom": "^17.0.1",
60
+ "classnames": "^2.3.2"
41
61
  },
42
62
  "keywords": [
43
63
  "rails",
@@ -0,0 +1,37 @@
1
+ import esbuild from "rollup-plugin-esbuild";
2
+ import pkg from "./package.json";
3
+ import postcss from "rollup-plugin-postcss";
4
+ import postcssPresetEnv from "postcss-preset-env";
5
+
6
+ export default {
7
+ input: "./src/components/stack.tsx",
8
+ external: ["react", "react-dom", "classnames"],
9
+ plugins: [
10
+ esbuild({
11
+ target: "es6",
12
+ }),
13
+ [
14
+ "@babel/plugin-transform-runtime",
15
+ {
16
+ regenerator: true,
17
+ },
18
+ ],
19
+ postcss({
20
+ extract: true,
21
+ plugins: [postcssPresetEnv({ preserve: true })],
22
+ }),
23
+ ],
24
+ output: {
25
+ dir: "dist/components",
26
+ plugins: [
27
+ {
28
+ file: pkg.main,
29
+ format: "cjs",
30
+ },
31
+ {
32
+ file: pkg.module,
33
+ format: "es",
34
+ },
35
+ ],
36
+ },
37
+ };
@@ -0,0 +1,252 @@
1
+ @mixin breakpoint-tablet {
2
+ @media (min-width: 640px) {
3
+ @content;
4
+ }
5
+ }
6
+ @mixin breakpoint-desktop {
7
+ @media (min-width: 890px) {
8
+ @content;
9
+ }
10
+ }
11
+ @mixin breakpoint-widescreen {
12
+ @media (min-width: 1280px) {
13
+ @content;
14
+ }
15
+ }
16
+
17
+ $sizes: (
18
+ 0: 0px,
19
+ 2: 2px,
20
+ 4: 4px,
21
+ 8: 8px,
22
+ 12: 12px,
23
+ 16: 16px,
24
+ 20: 20px,
25
+ 22: 22px,
26
+ 24: 24px,
27
+ 32: 32px,
28
+ 40: 40px,
29
+ 48: 48px,
30
+ 56: 56px,
31
+ 64: 64px,
32
+ );
33
+
34
+ @mixin line {
35
+ flex-direction: row;
36
+ align-items: center;
37
+ }
38
+
39
+ .stack {
40
+ display: flex;
41
+ flex-direction: column;
42
+ gap: 8px;
43
+
44
+ > * {
45
+ min-width: 0;
46
+ }
47
+
48
+ &--line {
49
+ @include line;
50
+ align-items: flex-start;
51
+ }
52
+
53
+ // align
54
+ &--align-start {
55
+ align-items: flex-start;
56
+ }
57
+ &--align-center {
58
+ align-items: center;
59
+ }
60
+ &--align-end {
61
+ align-items: flex-end;
62
+ }
63
+ &--align-stretch {
64
+ align-items: stretch;
65
+ }
66
+ &--align-baseline {
67
+ align-items: baseline;
68
+ }
69
+
70
+ // justify
71
+ &--justify-start {
72
+ justify-content: flex-start;
73
+ }
74
+ &--justify-center {
75
+ justify-content: center;
76
+ }
77
+ &--justify-end {
78
+ justify-content: flex-end;
79
+ }
80
+ &--justify-space-between {
81
+ justify-content: space-between;
82
+ }
83
+ &--justify-space-around {
84
+ justify-content: space-around;
85
+ }
86
+ &--justify-stretch {
87
+ justify-content: stretch;
88
+ > * {
89
+ min-width: min-content;
90
+ flex-grow: 1;
91
+ }
92
+ }
93
+ &--justify-equal-size {
94
+ > * {
95
+ flex: 1;
96
+ }
97
+ }
98
+
99
+ @each $size, $size-value in $sizes {
100
+ &--#{$size} {
101
+ gap: $size-value;
102
+ }
103
+ }
104
+
105
+ @include breakpoint-tablet {
106
+ @each $size, $size-value in $sizes {
107
+ &--tablet-#{$size} {
108
+ gap: $size-value;
109
+ }
110
+ }
111
+
112
+ &--line-tablet {
113
+ @include line;
114
+ }
115
+ &--align-tablet-start {
116
+ align-items: flex-start;
117
+ }
118
+ &--align-tablet-center {
119
+ align-items: center;
120
+ }
121
+ &--align-tablet-end {
122
+ align-items: flex-end;
123
+ }
124
+ &--align-tablet-stretch {
125
+ align-items: stretch;
126
+ }
127
+ &--align-tablet-baseline {
128
+ align-items: baseline;
129
+ }
130
+ &--justify-tablet-start {
131
+ justify-content: flex-start;
132
+ }
133
+ &--justify-tablet-center {
134
+ justify-content: center;
135
+ }
136
+ &--justify-tablet-end {
137
+ justify-content: flex-end;
138
+ }
139
+ &--justify-tablet-space-between {
140
+ justify-content: space-between;
141
+ }
142
+ &--justify-tablet-space-around {
143
+ justify-content: space-around;
144
+ }
145
+ &--justify-tablet-stretch {
146
+ justify-content: stretch;
147
+ }
148
+ &--justify-tablet-equal-size {
149
+ > * {
150
+ flex: 1;
151
+ }
152
+ }
153
+ }
154
+ @include breakpoint-desktop {
155
+ @each $size, $size-value in $sizes {
156
+ &--desktop-#{$size} {
157
+ gap: $size-value;
158
+ }
159
+ }
160
+
161
+ &--line-desktop {
162
+ @include line;
163
+ }
164
+ &--align-desktop-start {
165
+ align-items: flex-start;
166
+ }
167
+ &--align-desktop-center {
168
+ align-items: center;
169
+ }
170
+ &--align-desktop-end {
171
+ align-items: flex-end;
172
+ }
173
+ &--align-desktop-stretch {
174
+ align-items: stretch;
175
+ }
176
+ &--align-desktop-baseline {
177
+ align-items: baseline;
178
+ }
179
+ &--justify-desktop-start {
180
+ justify-content: flex-start;
181
+ }
182
+ &--justify-desktop-center {
183
+ justify-content: center;
184
+ }
185
+ &--justify-desktop-end {
186
+ justify-content: flex-end;
187
+ }
188
+ &--justify-desktop-space-between {
189
+ justify-content: space-between;
190
+ }
191
+ &--justify-desktop-space-around {
192
+ justify-content: space-around;
193
+ }
194
+ &--justify-desktop-stretch {
195
+ justify-content: stretch;
196
+ }
197
+ &--justify-desktop-equal-size {
198
+ > * {
199
+ flex: 1;
200
+ }
201
+ }
202
+ }
203
+ @include breakpoint-widescreen {
204
+ @each $size, $size-value in $sizes {
205
+ &--widescreen-#{$size} {
206
+ gap: $size-value;
207
+ }
208
+ }
209
+
210
+ &--line-widescreen {
211
+ @include line;
212
+ }
213
+ &--align-widescreen-start {
214
+ align-items: flex-start;
215
+ }
216
+ &--align-widescreen-center {
217
+ align-items: center;
218
+ }
219
+ &--align-widescreen-end {
220
+ align-items: flex-end;
221
+ }
222
+ &--align-widescreen-stretch {
223
+ align-items: stretch;
224
+ }
225
+ &--align-widescreen-baseline {
226
+ align-items: baseline;
227
+ }
228
+ &--justify-widescreen-start {
229
+ justify-content: flex-start;
230
+ }
231
+ &--justify-widescreen-center {
232
+ justify-content: center;
233
+ }
234
+ &--justify-widescreen-end {
235
+ justify-content: flex-end;
236
+ }
237
+ &--justify-widescreen-space-between {
238
+ justify-content: space-between;
239
+ }
240
+ &--justify-widescreen-space-around {
241
+ justify-content: space-around;
242
+ }
243
+ &--justify-widescreen-stretch {
244
+ justify-content: stretch;
245
+ }
246
+ &--justify-widescreen-equal-size {
247
+ > * {
248
+ flex: 1;
249
+ }
250
+ }
251
+ }
252
+ }