mirror of https://github.com/docusealco/docuseal
feat: add custom brand name + font feature (v1.2.0) (#11)
* feat: add custom brand name + font feature (v1.2.0) - Add BRAND_NAME_KEY, BRAND_NAME_FONT_KEY, BRAND_NAME_FONTS whitelist to AccountConfig - Modify _title.html.erb to render custom brand name with configurable font - Create _brand_name_form.html.erb partial with text input + font dropdown - Add brand name form to personalization_settings/show.html.erb - Add BRAND_NAME keys to PersonalizationSettingsController ALLOWED_KEYS - Apply brand name header in mailer layout - Add i18n translations (EN, ES, IT, FR, PT, DE, NL) - Env override support via DOCUSEAL_CONFIG_BRAND_NAME / DOCUSEAL_CONFIG_BRAND_NAME_FONT - When brand_name is unset, upstream DocuSeal text renders as before - When set, configured text renders in chosen font (CSS font-family inline) * fix: address review — correct font CSS fallback, system-ui quoting, server-side validation - Add brand_font_css helper to AccountConfig for proper CSS output - system-ui rendered unquoted; Inter uses sans-serif fallback; script fonts use cursive - Add server-side validation rejecting fonts not in BRAND_NAME_FONTS whitelist - Add invalid_font_selection i18n key * fix: use Rails form helpers for BetterHtml compatibility in brand name and UI visibility forms --------- Co-authored-by: Bob Develop <developbob50@gmail.com>pull/639/head
parent
db47f795ef
commit
900c33547a
@ -0,0 +1,40 @@
|
||||
<% brand_name_value, brand_name_locked = current_account.config_value(AccountConfig::BRAND_NAME_KEY)
|
||||
brand_font_value, brand_font_locked = current_account.config_value(AccountConfig::BRAND_NAME_FONT_KEY) %>
|
||||
<div class="my-4">
|
||||
<%= form_for AccountConfig.new, url: settings_personalization_path, method: :post, html: { autocomplete: 'off', class: 'space-y-4' } do |f| %>
|
||||
<%= f.hidden_field :key, value: AccountConfig::BRAND_NAME_KEY %>
|
||||
<div class="form-control">
|
||||
<label class="label">
|
||||
<span class="label-text font-medium"><%= t('brand_name') %></span>
|
||||
<% if brand_name_locked %>
|
||||
<span class="label-text-alt text-base-content/60" title="<%= t('locked_by_env') %>"><%= t('locked_by_env') %></span>
|
||||
<% end %>
|
||||
</label>
|
||||
<%= f.text_field :value, value: brand_name_value, placeholder: 'DocuSeal', disabled: brand_name_locked, class: 'base-input', dir: 'auto' %>
|
||||
</div>
|
||||
<div class="form-control pt-2">
|
||||
<%= f.button button_title(title: t('save'), disabled_with: t('saving')), class: 'base-button', disabled: brand_name_locked %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<%= form_for AccountConfig.new, url: settings_personalization_path, method: :post, html: { autocomplete: 'off', class: 'space-y-4 mt-4' } do |f| %>
|
||||
<%= f.hidden_field :key, value: AccountConfig::BRAND_NAME_FONT_KEY %>
|
||||
<div class="form-control">
|
||||
<label class="label">
|
||||
<span class="label-text font-medium"><%= t('brand_name_font') %></span>
|
||||
<% if brand_font_locked %>
|
||||
<span class="label-text-alt text-base-content/60" title="<%= t('locked_by_env') %>"><%= t('locked_by_env') %></span>
|
||||
<% end %>
|
||||
</label>
|
||||
<%= select_tag 'account_config[value]',
|
||||
options_for_select(
|
||||
[[t('default'), '']] + AccountConfig::BRAND_NAME_FONTS.map { |f| [f, f] },
|
||||
brand_font_value
|
||||
),
|
||||
class: 'base-input', disabled: brand_font_locked %>
|
||||
</div>
|
||||
<div class="form-control pt-2">
|
||||
<%= f.button button_title(title: t('save'), disabled_with: t('saving')), class: 'base-button', disabled: brand_font_locked %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
@ -1,2 +1,14 @@
|
||||
<%= render 'shared/logo' %>
|
||||
<span>DocuSeal</span>
|
||||
<% title_account = defined?(current_account) && current_account
|
||||
if title_account
|
||||
brand_name, _bn_locked = title_account.config_value(AccountConfig::BRAND_NAME_KEY)
|
||||
brand_font, _bf_locked = title_account.config_value(AccountConfig::BRAND_NAME_FONT_KEY)
|
||||
end
|
||||
brand_name = brand_name.presence || 'DocuSeal'
|
||||
brand_font = brand_font.presence %>
|
||||
<% brand_font_css = AccountConfig.brand_font_css(brand_font) %>
|
||||
<% if brand_font_css %>
|
||||
<span style="font-family: <%= brand_font_css %>;"><%= brand_name %></span>
|
||||
<% else %>
|
||||
<span><%= brand_name %></span>
|
||||
<% end %>
|
||||
|
||||
Loading…
Reference in new issue