myg 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: e4d0b04ee624e220e08a011661eac66dd3ffdb1fe48a6df162d7d71cde0009f7
4
+ data.tar.gz: f9f7c3df377b2b0083c8cf2e40eafd89d3092ecc0f358d423f78c211c8c4f83e
5
+ SHA512:
6
+ metadata.gz: 4921cfcb8c025fbcde88cd4287bea3c9855076cfb65e1286790c6e7d06e311a457730767b8adf5c881c771f040cddeecc30e4621b58de12bd8269f42b44c3a0f
7
+ data.tar.gz: 30f7efd4e65b79c2c29b9ff38d4944d3f3a3fd8991a010854825ff60cb9f9b0ef5d81580a1228017fa4b6124b20460718ebf04a660a28fd4d35809d1c84fa495
data/CHANGELOG.md ADDED
@@ -0,0 +1,9 @@
1
+ # Changelog
2
+
3
+ ### master
4
+
5
+ * nothing yet
6
+
7
+ ### 1.0.0 - 2018/02/05
8
+
9
+ * initial release
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2018 Jonas Hübotter
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.
data/README.md ADDED
@@ -0,0 +1,130 @@
1
+ # Myg on Rails
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/myg.svg)](https://badge.fury.io/rb/myg) <img src="https://travis-ci.org/jonhue/myg-rails.svg?branch=master" />
4
+
5
+ ---
6
+
7
+ ## Table of Contents
8
+
9
+ * [Installation](#installation)
10
+ * [Philosophy](#philosophy)
11
+ * [Usage](#usage)
12
+ * [Mozaic components](#mozaic-components)
13
+ * [To Do](#to-do)
14
+ * [Contributing](#contributing)
15
+ * [Contributors](#contributors)
16
+ * [Semantic versioning](#semantic-versioning)
17
+ * [License](#license)
18
+
19
+ ---
20
+
21
+ ## Installation
22
+
23
+ Myg on Rails works with Rails 5 onwards. You can add it to your `Gemfile` with:
24
+
25
+ ```ruby
26
+ gem 'myg-rails'
27
+ ```
28
+
29
+ And then execute:
30
+
31
+ $ bundle
32
+
33
+ Or install it yourself as:
34
+
35
+ $ gem install myg
36
+
37
+ If you always want to be up to date fetch the latest from GitHub in your `Gemfile`:
38
+
39
+ ```ruby
40
+ gem 'myg', github: 'jonhue/myg-rails'
41
+ ```
42
+
43
+ Now run the generator
44
+
45
+ $ rails g myg:install
46
+
47
+ Then add [Myg](https://github.com/jonhue/myg) to your asset pipeline:
48
+
49
+ ```js
50
+ //= require myg
51
+ ```
52
+ ```css
53
+ /*
54
+ *= require myg
55
+ */
56
+ ```
57
+
58
+ **Note:** If you are using a package manager like Yarn, make sure to fetch the latest versions instead.
59
+
60
+ ---
61
+
62
+ ## Philosophy
63
+
64
+ ...
65
+
66
+ ---
67
+
68
+ ## Usage
69
+
70
+ ...
71
+
72
+ ### Mozaic components
73
+
74
+ These are the components currently supported by Myg on Rails:
75
+
76
+ * [`checkbox`](components/myg/checkbox.md)
77
+ * [`form-field`](components/myg/form-field.md)
78
+ * [`radio`](components/myg/radio.md)
79
+
80
+ You feel a component is missing? Create an issue to make us aware, or implement it yourself. Pull requests are welcome.
81
+
82
+ ---
83
+
84
+ ## To Do
85
+
86
+ [Here](https://github.com/jonhue/myg-rails/projects/1) is the full list of current projects.
87
+
88
+ To propose your ideas, initiate the discussion by adding a [new issue](https://github.com/jonhue/myg-rails/issues/new).
89
+
90
+ ---
91
+
92
+ ## Contributing
93
+
94
+ We hope that you will consider contributing to Myg on Rails. Please read this short overview for some information about how to get started:
95
+
96
+ [Learn more about contributing to this repository](CONTRIBUTING.md), [Code of Conduct](CODE_OF_CONDUCT.md)
97
+
98
+ ### Contributors
99
+
100
+ Give the people some :heart: who are working on this project. See them all at:
101
+
102
+ https://github.com/jonhue/myg-rails/graphs/contributors
103
+
104
+ ### Semantic Versioning
105
+
106
+ Myg on Rails follows Semantic Versioning 2.0 as defined at http://semver.org.
107
+
108
+ ## License
109
+
110
+ MIT License
111
+
112
+ Copyright (c) 2018 Jonas Hübotter
113
+
114
+ Permission is hereby granted, free of charge, to any person obtaining a copy
115
+ of this software and associated documentation files (the "Software"), to deal
116
+ in the Software without restriction, including without limitation the rights
117
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
118
+ copies of the Software, and to permit persons to whom the Software is
119
+ furnished to do so, subject to the following conditions:
120
+
121
+ The above copyright notice and this permission notice shall be included in all
122
+ copies or substantial portions of the Software.
123
+
124
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
125
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
126
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
127
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
128
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
129
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
130
+ SOFTWARE.
@@ -0,0 +1,34 @@
1
+ module Myg
2
+ module ThemeHelper
3
+
4
+ def theme theme = nil
5
+ theme ||= cookies[:theme] || Myg.configuration.theme
6
+ if Myg.configuration.auto && theme == 'auto'
7
+ if Time.now < Time.parse(Myg.configuration.theme_day_time) || Time.now > Time.parse(Myg.configuration.theme_night_time)
8
+ theme = Myg.configuration.theme_day
9
+ else
10
+ theme = Myg.configuration.theme_night
11
+ end
12
+ end
13
+ theme
14
+ end
15
+
16
+ def set_theme theme
17
+ cookies[:theme] = theme
18
+ theme
19
+ end
20
+
21
+ def theme_class
22
+ begin
23
+ "myg-theme--#{current_theme}"
24
+ rescue NoMethodError
25
+ "myg-theme--#{theme}"
26
+ end
27
+ end
28
+
29
+ def theme_available? theme
30
+ Myg.configuration.themes.include? theme
31
+ end
32
+
33
+ end
34
+ end
@@ -0,0 +1 @@
1
+ <%= component 'mdc-checkbox', class_name: 'myg-checkbox', label: options[:label], checked: options[:checked], disabled: options[:disabled] %>
@@ -0,0 +1 @@
1
+ <%= component 'mdc-form-field', class_name: 'myg-form-field' %>
@@ -0,0 +1 @@
1
+ <%= component 'mdc-radio', class_name: 'myg-radio', label: options[:label], checked: options[:checked], disabled: options[:disabled] %>
@@ -0,0 +1,23 @@
1
+ require 'rails/generators'
2
+ require 'rails/generators/migration'
3
+
4
+ class Myg::InstallGenerator < Rails::Generators::Base
5
+
6
+ include Rails::Generators::Migration
7
+
8
+ source_root File.join File.dirname(__FILE__), '../templates/install'
9
+ desc 'Install Myg on Rails'
10
+
11
+ def create_initializer
12
+ template 'initializer.rb', 'config/initializers/myg.rb'
13
+ end
14
+
15
+ def create_assets
16
+ template 'myg.sass', "#{Myg.configuration.assets_dir}/myg.sass"
17
+ template '_myg.sass', "#{Myg.configuration.assets_dir}/_myg.sass"
18
+ template '_variables.sass', "#{Myg.configuration.assets_dir}/_variables.sass"
19
+ template 'theme/theme.sass', "#{Myg.configuration.assets_dir}/theme/theme.sass"
20
+ template 'theme/_default.scss', "#{Myg.configuration.assets_dir}/theme/_default.scss"
21
+ end
22
+
23
+ end
@@ -0,0 +1,17 @@
1
+ require 'rails/generators'
2
+ require 'rails/generators/migration'
3
+
4
+ class Myg::ThemeGenerator < Rails::Generators::Base
5
+
6
+ include Rails::Generators::Migration
7
+
8
+ source_root File.join File.dirname(__FILE__), '../templates/theme'
9
+ desc 'Add Myg theme'
10
+
11
+ class_option :name, desc: 'Theme name', type: :string, aliases: '-n'
12
+
13
+ def create_assets
14
+ template '_theme.scss', "#{Myg.configuration.assets_dir}/theme/_#{options[:name]}.scss"
15
+ end
16
+
17
+ end
@@ -0,0 +1 @@
1
+ @import "myg/src/myg"
@@ -0,0 +1 @@
1
+ @import "theme/_default"
@@ -0,0 +1,30 @@
1
+ Myg.configure do |config|
2
+
3
+ # Path to Myg styles directory
4
+ # config.assets_dir = 'app/assets/stylesheets/myg'
5
+
6
+
7
+ ##### MYG-THEME #####
8
+
9
+ # Array of available themes
10
+ # config.themes = ['default']
11
+
12
+ # Default theme
13
+ # config.theme = 'default'
14
+
15
+ ### Automatic themes ###
16
+
17
+ # Enable automatic themes
18
+ # config.theme_auto = false
19
+
20
+ # Day theme
21
+ # config.theme_day = 'light'
22
+ # Night theme
23
+ # config.theme_night = 'dark'
24
+
25
+ # Beginning of daytime
26
+ # config.theme_day_time = '6:00 am'
27
+ # Beginning of nighttime
28
+ # config.theme_night_time = '6:00 pm'
29
+
30
+ end
@@ -0,0 +1,8 @@
1
+ // Myg variables
2
+ @import "_variables"
3
+
4
+ // Myg
5
+ @import "_myg"
6
+
7
+ // Myg enhancements
8
+ @import "theme/theme"
@@ -0,0 +1,27 @@
1
+ $myg-theme: (
2
+ accent: (
3
+ light: #4063e8,
4
+ base: #042ecb,
5
+ dark: #052ab3,
6
+ contrast: #ffffff
7
+ ),
8
+ text: (
9
+ lighter: #bec7cf,
10
+ light: #97a4b0,
11
+ base: #657786,
12
+ dark: #3d4553,
13
+ darker: #14171A
14
+ ),
15
+ background: (
16
+ lighter: #fcfcfc,
17
+ light: #ffffff,
18
+ base: #ffffff,
19
+ dark: #ecf2f7,
20
+ darker: #ebf5fe
21
+ ),
22
+ border: #dce2e7,
23
+ box-shadow: rgba(#000, .05),
24
+ error: #f6809a,
25
+ success: #6adb83,
26
+ overlay: transparentize(#e7eCf0, 0.13)
27
+ );
@@ -0,0 +1,2 @@
1
+ html
2
+ // +theme($myg-theme--custom)
@@ -0,0 +1,27 @@
1
+ $myg-theme--<%= options[:name] %>: (
2
+ accent: (
3
+ light: #4063e8,
4
+ base: #042ecb,
5
+ dark: #052ab3,
6
+ contrast: #ffffff
7
+ ),
8
+ text: (
9
+ lighter: #bec7cf,
10
+ light: #97a4b0,
11
+ base: #657786,
12
+ dark: #3d4553,
13
+ darker: #14171A
14
+ ),
15
+ background: (
16
+ lighter: #fcfcfc,
17
+ light: #ffffff,
18
+ base: #ffffff,
19
+ dark: #ecf2f7,
20
+ darker: #ebf5fe
21
+ ),
22
+ border: #dce2e7,
23
+ box-shadow: rgba(#000, .05),
24
+ error: #f6809a,
25
+ success: #6adb83,
26
+ overlay: transparentize(#e7eCf0, 0.13)
27
+ );
data/lib/myg.rb ADDED
@@ -0,0 +1,11 @@
1
+ require 'material-components-web'
2
+ require 'myg/version'
3
+
4
+ module Myg
5
+
6
+ require 'myg/configuration'
7
+
8
+ require 'myg/engine'
9
+ require 'myg/railtie'
10
+
11
+ end
@@ -0,0 +1,35 @@
1
+ module Myg
2
+
3
+ class << self
4
+ attr_accessor :configuration
5
+ end
6
+
7
+ def self.configure
8
+ self.configuration ||= Configuration.new
9
+ yield configuration
10
+ end
11
+
12
+ class Configuration
13
+
14
+ attr_accessor :assets_dir
15
+ attr_accessor :themes
16
+ attr_accessor :theme
17
+ attr_accessor :theme_auto
18
+ attr_accessor :theme_day
19
+ attr_accessor :theme_night
20
+ attr_accessor :theme_day_time
21
+ attr_accessor :theme_night_time
22
+
23
+ def initialize
24
+ @assets_dir = 'app/assets/stylesheets/myg'
25
+ @themes = ['default']
26
+ @theme = 'default'
27
+ @theme_auto = false
28
+ @theme_day = 'light'
29
+ @theme_night = 'dark'
30
+ @theme_day_time = '6:00 am'
31
+ @theme_night_time = '6:00 pm'
32
+ end
33
+
34
+ end
35
+ end
data/lib/myg/engine.rb ADDED
@@ -0,0 +1,6 @@
1
+ require 'rails/railtie'
2
+
3
+ module Myg
4
+ class Engine < ::Rails::Engine
5
+ end
6
+ end
@@ -0,0 +1,21 @@
1
+ require 'rails/railtie'
2
+
3
+ module Myg
4
+ class Railtie < Rails::Railtie
5
+
6
+ initializer 'myg.mozaic' do
7
+ Mozaic.configure do |config|
8
+ config.define_component 'myg/checkbox', class_name: false, label: false, checked: false, disabled: false
9
+ config.define_component 'myg/form-field'
10
+ config.define_component 'myg/radio', class_name: false, label: false, checked: false, disabled: false
11
+ end
12
+ end
13
+
14
+ initializer 'myg.action_controller' do
15
+ ActiveSupport.on_load :action_controller do
16
+ include Myg::ThemeHelper
17
+ end
18
+ end
19
+
20
+ end
21
+ end