Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add alignment options to widget settings #348

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,12 @@ You can customize the CSS selector, by setting
config.inbox.custom_activator = '.intercom-link'
```

You can choose widget alignment, by setting

```ruby
config.alignment = :left
```

You can hide default launcher button, by setting

```ruby
Expand Down
1 change: 1 addition & 0 deletions lib/intercom-rails/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ def self.reset!
config_accessor :enabled_environments, &ARRAY_VALIDATOR
config_accessor :include_for_logged_out_users
config_accessor :hide_default_launcher
config_accessor :alignment
config_accessor :api_base
config_accessor :encrypted_mode

Expand Down
1 change: 1 addition & 0 deletions lib/intercom-rails/script_tag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def intercom_settings
hsh[:widget] = widget_options if widget_options.present?
hsh[:company] = company_details if company_details.present?
hsh[:hide_default_launcher] = Config.hide_default_launcher if Config.hide_default_launcher
hsh[:alignment] = Config.alignment if Config.alignment
hsh[:api_base] = Config.api_base if Config.api_base
hsh
end
Expand Down
2 changes: 2 additions & 0 deletions lib/rails/generators/intercom/config/intercom.rb.erb
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ IntercomRails.config do |config|
# open the messenger.
#
# config.inbox.style = :custom

# config.alignment = :left
#
# If you'd like to use your own link activator CSS selector
# uncomment this line and clicks on any element that matches the query will
Expand Down
5 changes: 5 additions & 0 deletions spec/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@
expect(IntercomRails.config.hide_default_launcher).to eq(true)
end

it 'gets/sets alignment' do
IntercomRails.config.alignment = :left
expect(IntercomRails.config.alignment).to eq(:left)
end

it 'gets/sets api_base' do
IntercomRails.config.api_base = "https://abcde1.intercom-messenger.com"
expect(IntercomRails.config.api_base).to eq("https://abcde1.intercom-messenger.com")
Expand Down
4 changes: 4 additions & 0 deletions spec/script_tag_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ def sha256_hmac(secret, input)
IntercomRails.config.inbox.custom_activator = '.intercom'
expect(ScriptTag.new.intercom_settings['widget']).to eq({'activator' => '.intercom'})
end
it 'knows about :alignment' do
IntercomRails.config.alignment = :left
expect(ScriptTag.new.intercom_settings['hide_default_launcher']).to eq(:left)
end
it 'knows about :hide_default_launcher' do
IntercomRails.config.hide_default_launcher = true
expect(ScriptTag.new.intercom_settings['hide_default_launcher']).to eq(true)
Expand Down