shimmer 0.0.28 → 0.0.30

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in shimmer.gemspec
6
+ gemspec path: ".."
7
+
8
+ gem "rails", "~> 7.0.0"
9
+ gem "propshaft"
10
+ gem "sqlite3"
11
+ gem "puma"
12
+ gem "jsbundling-rails"
13
+ gem "turbo-rails"
14
+ gem "stimulus-rails"
15
+ gem "cssbundling-rails"
16
+ gem "jbuilder"
17
+ gem "bootsnap", require: false
18
+ gem "dotenv"
19
+ gem "slim-rails"
20
+ gem "awesome_print"
21
+ gem "dotenv-rails"
22
+
23
+ group :development, :test do
24
+ gem "debug", platforms: %i[mri mingw x64_mingw]
25
+ gem "rake"
26
+ gem "rspec-rails"
27
+ gem "rspec-retry"
28
+ gem "pry"
29
+ gem "pry-rails"
30
+ gem "pry-byebug"
31
+ gem "pry-doc"
32
+ gem "guard"
33
+ gem "guard-rspec"
34
+ gem "capybara"
35
+ gem "rack_session_access"
36
+ gem "cuprite"
37
+ gem "standard"
38
+ gem "rubocop"
39
+ gem "rubocop-rails"
40
+ gem "rubocop-performance"
41
+ gem "rubocop-rspec"
42
+ gem "rubocop-rake"
43
+ end
44
+
45
+ group :development do
46
+ gem "web-console"
47
+ gem "annotate"
48
+ end
@@ -10,7 +10,7 @@ module Shimmer
10
10
  def request_details(params)
11
11
  name = params[:user] ? JSON.parse(params[:user])["name"] : {}
12
12
  headers = {
13
- 'Content-Type': "application/x-www-form-urlencoded"
13
+ "Content-Type": "application/x-www-form-urlencoded"
14
14
  }
15
15
  form = {
16
16
  grant_type: "authorization_code",
@@ -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
@@ -72,7 +72,7 @@ module Shimmer
72
72
  classes << "input--error"
73
73
  errors = safe_join(object.errors[method].map { |e| content_tag :div, e, class: "input__error" })
74
74
  end
75
- label = label == false ? nil : self.label(label_method || method, label, class: "input__label")
75
+ label = (label == false) ? nil : self.label(label_method || method, label, class: "input__label")
76
76
  description = description.presence ? content_tag(:div, description, class: "input__description") : nil
77
77
  content_tag(:div, safe_join([label, content, description, errors, extra].compact), class: ["input"] + classes, **options)
78
78
  end
@@ -3,16 +3,22 @@
3
3
  module Shimmer
4
4
  class Config
5
5
  include Singleton
6
+
6
7
  class MissingConfigError < StandardError; end
7
8
 
8
- def method_missing(method_name)
9
+ def method_missing(method_name, **options)
10
+ default_provided = options.key?(:default)
11
+ default_value = options.delete(:default) if default_provided
12
+ raise ArgumentError, "unknown option#{"s" if options.length > 1}: #{options.keys.join(", ")}." if options.any?
13
+
9
14
  method_name = method_name.to_s
10
15
  type = :string
11
16
  key = method_name.delete_suffix("!").delete_suffix("?")
12
17
  required = method_name.end_with?("!")
13
18
  type = :bool if method_name.end_with?("?")
14
19
  value = ENV[key.upcase].presence
15
- value ||= Rails.application.credentials.send(key)
20
+ value ||= Rails.application.credentials.public_send(key)
21
+ value = default_value if value.nil?
16
22
  raise MissingConfigError, "#{key.upcase} environment value is missing" if required && value.blank?
17
23
 
18
24
  coerce value, type
@@ -25,7 +31,7 @@ module Shimmer
25
31
  private
26
32
 
27
33
  def coerce(value, type)
28
- return !value.in?(["n", "0", "no", "false"]) if type == :bool && value.is_a?(String)
34
+ return !value.downcase.in?(["n", "0", "no", "false"]) if type == :bool && value.is_a?(String)
29
35
 
30
36
  value
31
37
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Shimmer
4
- VERSION = "0.0.28"
4
+ VERSION = "0.0.30"
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
+ }
@@ -0,0 +1,81 @@
1
+ import React from "react";
2
+ import classnames from "classnames";
3
+ import "./stack.scss";
4
+
5
+ type Justify =
6
+ | "start"
7
+ | "center"
8
+ | "end"
9
+ | "space-between"
10
+ | "space-around"
11
+ | "stretch"
12
+ | "equal-size";
13
+ type Align = "start" | "center" | "end" | "stretch" | "baseline";
14
+
15
+ export interface Props {
16
+ children: React.ReactNode;
17
+ gap?: number;
18
+ gapTablet?: number;
19
+ gapDesktop?: number;
20
+ gapWidescreen?: number;
21
+ line?: boolean;
22
+ lineTablet?: boolean;
23
+ lineDesktop?: boolean;
24
+ lineWidescreen?: boolean;
25
+ align?: Align;
26
+ alignTablet?: Align;
27
+ alignDesktop?: Align;
28
+ alignWidescreen?: Align;
29
+ justify?: Justify;
30
+ justifyTablet?: Justify;
31
+ justifyDesktop?: Justify;
32
+ justifyWidescreen?: Justify;
33
+ }
34
+
35
+ export function Stack({
36
+ children,
37
+ gap = 8,
38
+ gapTablet,
39
+ gapDesktop,
40
+ gapWidescreen,
41
+ line,
42
+ lineTablet,
43
+ lineDesktop,
44
+ lineWidescreen,
45
+ align,
46
+ alignTablet,
47
+ alignDesktop,
48
+ alignWidescreen,
49
+ justify,
50
+ justifyTablet,
51
+ justifyDesktop,
52
+ justifyWidescreen,
53
+ }: Props): JSX.Element {
54
+ return (
55
+ <div
56
+ className={classnames(
57
+ "stack",
58
+ gap && `stack--${gap}`,
59
+ gapTablet && `stack--tablet-${gapTablet}`,
60
+ gapDesktop && `stack--desktop-${gapDesktop}`,
61
+ gapWidescreen && `stack--widescreen-${gapWidescreen}`,
62
+ align && `stack--align-${align}`,
63
+ alignTablet && `stack--align-tablet-${alignTablet}`,
64
+ alignDesktop && `stack--align-desktop-${alignDesktop}`,
65
+ alignWidescreen && `stack--align-widescreen-${alignWidescreen}`,
66
+ justify && `stack--justify-${justify}`,
67
+ justifyTablet && `stack--justify-tablet-${justifyTablet}`,
68
+ justifyDesktop && `stack--justify-desktop-${justifyDesktop}`,
69
+ justifyWidescreen && `stack--justify-widescreen-${justifyWidescreen}`,
70
+ {
71
+ "stack--line": line,
72
+ "stack--line-tablet": lineTablet,
73
+ "stack--line-desktop": lineDesktop,
74
+ "stack--line-widescreen": lineWidescreen,
75
+ }
76
+ )}
77
+ >
78
+ {children}
79
+ </div>
80
+ );
81
+ }
data/stack.png ADDED
Binary file
data/tsconfig.json CHANGED
@@ -21,8 +21,9 @@
21
21
  "suppressImplicitAnyIndexErrors": true,
22
22
  "target": "es6",
23
23
  "isolatedModules": true,
24
- "declaration": true
24
+ "declaration": true,
25
+ "jsx": "react"
25
26
  },
26
27
  "exclude": ["node_modules", "dist"],
27
- "files": ["src/index.ts"]
28
+ "files": ["src/index.ts", "src/components/stack.tsx"]
28
29
  }