Skip to content

Commit

Permalink
Add icons for selected text-enabled plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
fsbraun committed Mar 21, 2024
1 parent 507dd25 commit 784d676
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
10 changes: 9 additions & 1 deletion djangocms_frontend/contrib/icon/cms_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,15 @@ class IconPlugin(
model = models.Icon
form = forms.IconForm
text_enabled = True

text_icon = (
'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" '
'class="bi bi-emoji-sunglasses" viewBox="0 0 16 16"><path d="M4.968 9.75a.5.5 0 1 0-.866.5A4.5 4.5 '
'0 0 0 8 12.5a4.5 4.5 0 0 0 3.898-2.25.5.5 0 1 0-.866-.5A3.5 3.5 0 0 1 8 11.5a3.5 3.5 0 0 1-3.032-1.75M7 '
'5.116V5a1 1 0 0 0-1-1H3.28a1 1 0 0 0-.97 1.243l.311 1.242A2 2 0 0 0 4.561 8H5a2 2 0 0 0 1.994-1.839A3 '
'3 0 0 1 8 6c.393 0 .74.064 1.006.161A2 2 0 0 0 11 8h.438a2 2 0 0 0 1.94-1.515l.311-1.242A1 1 0 0 0 '
'12.72 4H10a1 1 0 0 0-1 1v.116A4.2 4.2 0 0 0 8 5c-.35 0-.69.04-1 .116"/><path d="M16 8A8 8 0 1 1 0 8a8 8 '
'0 0 1 16 0m-1 0A7 7 0 1 0 1 8a7 7 0 0 0 14 0"/></svg>'
)
fieldsets = [
(
None,
Expand Down
7 changes: 7 additions & 0 deletions djangocms_frontend/contrib/image/cms_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ class ImagePlugin(
form = forms.ImageForm

text_enabled = True
text_icon = (
'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-image" '
'viewBox="0 0 16 16"><path d="M6.002 5.5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0"/>'
'<path d="M2.002 1a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V3a2 2 0 0 0-2-2zm12 1a1 1 0 0 1 1 '
'1v6.5l-3.777-1.947a.5.5 0 0 0-.577.093l-3.71 3.71-2.66-1.772a.5.5 0 0 0-.63.062L1.002 12V3a1 1 0 0 1 '
'1-1z"/></svg>'
)

change_form_template = "djangocms_frontend/admin/image.html"

Expand Down
7 changes: 7 additions & 0 deletions djangocms_frontend/contrib/link/cms_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,13 @@ class LinkPlugin(
form = forms.LinkForm
change_form_template = "djangocms_frontend/admin/link.html"
text_enabled = True
text_icon = (
'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-link-45deg" '
'viewBox="0 0 16 16"><path d="M4.715 6.542 3.343 7.914a3 3 0 1 0 4.243 4.243l1.828-1.829A3 3 0 0 0 8.586 '
'5.5L8 6.086a1 1 0 0 0-.154.199 2 2 0 0 1 .861 3.337L6.88 11.45a2 2 0 1 1-2.83-2.83l.793-.792a4 4 0 0 '
'1-.128-1.287z"/><path d="M6.586 4.672A3 3 0 0 0 7.414 9.5l.775-.776a2 2 0 0 1-.896-3.346L9.12 3.55a2 2 0 '
'1 1 2.83 2.83l-.793.792c.112.42.155.855.128 1.287l1.372-1.372a3 3 0 1 0-4.243-4.243z"/></svg>'
)
allow_children = True

fieldsets = UILINK_FIELDSET
Expand Down
2 changes: 1 addition & 1 deletion djangocms_frontend/contrib/link/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def __init__(self, *args, **kwargs):
def get_choices(self):
if MINIMUM_INPUT_LENGTH == 0:
return get_choices(self.request)
if not self.is_bound: # find inital value
if not self.is_bound: # find initial value
int_link_field = self.fields["internal_link"]
initial = self.get_initial_for_field(int_link_field, "internal_link")
if initial: # Initial set?
Expand Down

0 comments on commit 784d676

Please sign in to comment.