Skip to content

Commit

Permalink
Merge pull request #122 from baoagency/importmaps
Browse files Browse the repository at this point in the history
Importmaps
  • Loading branch information
kirillplatonov authored Oct 5, 2021
2 parents b27523b + 4128327 commit abcf218
Show file tree
Hide file tree
Showing 59 changed files with 245 additions and 8,806 deletions.
14 changes: 7 additions & 7 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ PATH
remote: .
specs:
polaris_view_components (0.2.0)
rails (>= 5.0.0, < 7.0.0)
rails (>= 5.0.0, < 8.0.0)
view_component (~> 2.0, >= 2.0.0)

GEM
Expand Down Expand Up @@ -92,16 +92,16 @@ GEM
nokogiri (>= 1.5.9)
mail (2.7.1)
mini_mime (>= 0.1.1)
marcel (1.0.1)
marcel (1.0.2)
method_source (1.0.0)
mini_mime (1.1.0)
mini_mime (1.1.1)
minitest (5.14.4)
nio4r (2.5.8)
nokogiri (1.12.1-arm64-darwin)
nokogiri (1.12.5-arm64-darwin)
racc (~> 1.4)
nokogiri (1.12.1-x86_64-darwin)
nokogiri (1.12.5-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.12.1-x86_64-linux)
nokogiri (1.12.5-x86_64-linux)
racc (~> 1.4)
pry (0.14.1)
coderay (~> 1.1)
Expand Down Expand Up @@ -150,7 +150,7 @@ GEM
thor (1.1.0)
tzinfo (2.0.4)
concurrent-ruby (~> 1.0)
view_component (2.39.0)
view_component (2.40.0)
activesupport (>= 5.0.0, < 8.0)
method_source (~> 1.0)
websocket-driver (0.7.5)
Expand Down
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ Define Polaris style on your `<body>` tag:
<body style="<%= polaris_body_styles %>">
```

### Importmaps

Add to `config/importmap.rb`:

```rb
pin "polaris-view-components", to: "polaris_view_components.js"
```

### NPM

Install NPM package:
```bash
yarn add polaris-view-components
Expand All @@ -55,7 +65,7 @@ Add to `app/javascript/controllers/index.js`:
```javascript
// Polaris ViewComponents
import { registerPolarisControllers } from "polaris-view-components"
registerPolarisControllers(application)
registerPolarisControllers(Stimulus)
```

## Dependencies
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,7 @@
import { Controller } from "stimulus";
import { Controller } from "@hotwired/stimulus";

function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}

class _class$2 extends Controller {
class ResourceItem extends Controller {
static targets=[ "link" ];
open(event) {
if (this.hasLinkTarget && this.targetNotClickable(event.target)) {
this.linkTarget.click();
Expand All @@ -25,19 +12,26 @@ class _class$2 extends Controller {
}
}

_defineProperty(_class$2, "targets", [ "link" ]);

class _class$1 extends Controller {
class Select extends Controller {
static targets=[ "selectedOption" ];
update(event) {
const select = event.currentTarget;
const option = select.options[select.selectedIndex];
this.selectedOptionTarget.innerText = option.text;
}
}

_defineProperty(_class$1, "targets", [ "selectedOption" ]);

class _class extends Controller {
class TextField extends Controller {
static targets=[ "input", "clearButton", "characterCount" ];
static classes=[ "hasValue", "clearButtonHidden" ];
static values={
value: String,
labelTemplate: String,
textTemplate: String,
step: Number,
min: Number,
max: Number
};
connect() {
this.syncValue();
this.stepValue = this.inputTarget.getAttribute("step");
Expand Down Expand Up @@ -104,23 +98,10 @@ class _class extends Controller {
}
}

_defineProperty(_class, "targets", [ "input", "clearButton", "characterCount" ]);

_defineProperty(_class, "classes", [ "hasValue", "clearButtonHidden" ]);

_defineProperty(_class, "values", {
value: String,
labelTemplate: String,
textTemplate: String,
step: Number,
min: Number,
max: Number
});

function registerPolarisControllers(application) {
application.register("polaris-resource-item", _class$2);
application.register("polaris-select", _class$1);
application.register("polaris-text-field", _class);
application.register("polaris-resource-item", ResourceItem);
application.register("polaris-select", Select);
application.register("polaris-text-field", TextField);
}

export { _class$2 as ResourceItem, _class$1 as Select, _class as TextField, registerPolarisControllers };
export { ResourceItem, Select, TextField, registerPolarisControllers };
2 changes: 1 addition & 1 deletion app/components/polaris/dropzone/controller.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Controller } from 'stimulus'
import { Controller } from "@hotwired/stimulus"

import { fileAccepted, getDataTransferFiles } from './utils'

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Controller } from 'stimulus'
import { Controller } from "@hotwired/stimulus"

export default class extends Controller {
static targets = ['link']
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Controller } from 'stimulus'
import { Controller } from "@hotwired/stimulus"

export default class extends Controller {
static targets = ['selectedOption']
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Controller } from 'stimulus'
import { Controller } from "@hotwired/stimulus"

export default class extends Controller {
static targets = ['input', 'clearButton', 'characterCount']
Expand Down
13 changes: 0 additions & 13 deletions babel.config.json

This file was deleted.

1 change: 0 additions & 1 deletion demo/.browserslistrc

This file was deleted.

37 changes: 12 additions & 25 deletions demo/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,22 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby "3.0.2"

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails', branch: 'main'
gem 'rails', '~> 6.1.4'
# Use Puma as the app server
gem 'puma', '~> 5.0'
# Use SCSS for stylesheets
gem 'sass-rails', '>= 6'
# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker
gem 'webpacker', '~> 5.0'
# Use Active Model has_secure_password
# gem 'bcrypt', '~> 3.1.7'
gem "rails", "~> 7.0.0.alpha2"
gem "puma", "~> 5.0"
gem "bootsnap", ">= 1.4.4", require: false
gem "tzinfo-data", platforms: %i[ mingw mswin x64_mingw jruby ]

# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.4.4', require: false
gem "importmap-rails", ">= 0.3.4"
gem "turbo-rails", ">= 0.7.11"
gem "stimulus-rails", ">= 0.4.0"

gem "polaris_view_components", path: "../"
gem "lookbook"

group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
gem 'pry-rails'
gem 'foreman'
gem "foreman"
end

group :development do
# Access an interactive console on exception pages or by calling 'console' anywhere in the code.
gem 'web-console', '>= 4.1.0'
gem 'listen', '~> 3.3'
gem "web-console", ">= 4.1.0"
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

gem "polaris_view_components", path: "../"
gem 'lookbook', github: 'allmarkedup/lookbook'
Loading

1 comment on commit abcf218

@dan-gamble
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😍

Please sign in to comment.