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

BP-1293: Add theming support to new rich-text editor for basic redactor configuration #240

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
94a3604
BP-1293: Adding Redactor overrides in entry
jovana-marceta Oct 30, 2024
19895ee
BP-1293: Extending redactor generator mixins
jovana-marceta Oct 30, 2024
1196aa4
BP-1293: Add redactor generators for buttons and table styles
jovana-marceta Nov 5, 2024
162bab4
BP-1293: Adding redactor checkboxes generator
jovana-marceta Nov 5, 2024
0444e4e
BP-1293: Refactoring redactor styles
jovana-marceta Nov 6, 2024
71f0a1c
Use mixin for row coloring from foundation
jovana-marceta Nov 6, 2024
6f32991
BP-1293: Inherit angular material checkbox background and change alia…
Nov 8, 2024
d58d056
Rename redactor lib
jovana-marceta Nov 12, 2024
22133a9
Move non-theming related variables outside of redactor mixins
jovana-marceta Nov 12, 2024
dead72d
BP-1293: Add redactor layout generator and clean up generator file
jovana-marceta Nov 12, 2024
6768b1a
BP-1293: Inherit table even background from angular material
jovana-marceta Nov 12, 2024
80792fb
BP-1293: Inherit material body text color
jovana-marceta Nov 12, 2024
f4151f9
BP-1293: Make redactor typography generator more redeable
jovana-marceta Nov 13, 2024
b9f241c
BP-1293: Rename folder
jovana-marceta Nov 13, 2024
8d2d02d
BP-1293: Resolve review suggestions
jovana-marceta Nov 14, 2024
5a54b11
BP-1293: Get rid of variables
jovana-marceta Nov 14, 2024
194e84e
rename checkbox variables
jovana-marceta Nov 14, 2024
2bdd9ea
rename toolbar generator
jovana-marceta Nov 14, 2024
6977b0b
BP-1293: Add missing sign on buttons generator variable
jovana-marceta Nov 20, 2024
d4dda13
BP-1293: Get rid of checkboxes duplicated extraction
jovana-marceta Nov 20, 2024
0789b8f
Get rid of toolbar generator duplicated extraction retrieval
jovana-marceta Nov 20, 2024
608e968
Additional buttons and checkboxes file refactoring
jovana-marceta Nov 26, 2024
b4ea198
Make buttons generator more redeable
jovana-marceta Nov 26, 2024
2bb570a
Refactoring checkbox and toolbar generator
jovana-marceta Nov 26, 2024
2102dcc
Fixed indentation for buttons generator
jovana-marceta Nov 26, 2024
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
2 changes: 2 additions & 0 deletions libs/entry-components/styles/_generator.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
@use 'modules/components/toggle/generator' as toggle;
@use 'modules/default-theme' as default;
@use 'modules/vendors/angular-material/generator' as material-theme;
@use 'modules/vendors/redactor/generator' as redactor;
@use 'sass:map';
@use 'partials/theming';

Expand All @@ -23,4 +24,5 @@
@include dialogs.generate-from($merged-theme);
@include checkboxes.generate-from($merged-theme);
@include toggle.generate-from($merged-theme);
@include redactor.generate-from($custom-theme);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
@use 'sass:map';

$material-button-background: #237BBB;

@mixin generate-from($theme) {

$theming-buttons: map.get($theme, 'general', 'fonts', 'buttons');

.enigmatry-redactor-content button {
@if $theming-buttons {
background-color: map.get($theme, 'general', 'colors', 'primary');
font: {
family: map.get($theming-buttons, 'family');
size: map.get($theming-buttons, 'size');
}
letter-spacing: map.get($theming-buttons, 'letter-spacing');
}
@else {
background-color: $material-button-background;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
@use 'sass:map';
@use 'tables-generator' as tables;
@use 'buttons-generator' as buttons;
@use 'typography-generator' as typography;

$redactor-checkboxes-selector: '[data-rx-type = 'todoitem'] input:checked::before';
$default-material-checkbox: #E94887;

@mixin generate-from($theme) {
@include typography.generate-from($theme);
@include tables.generate-from($theme);
@include buttons.generate-from($theme);

$theming-colors: map.get($theme, 'general', 'colors');
$theming-checkboxes: map.get($theme, 'general', 'checkboxes');

.enigmatry-redactor-content {
.rx-main-container, .rx-toolbox-container {
@if map.get($theme, 'general', 'inputs', 'background') {
background: map.get($theme, 'general', 'inputs', 'background');
}
@else {
background: transparent;
}
}

.rx-toolbar-buttons .rx-button {
&.active, &:hover {
@if map.get($theme, 'general', 'inputs', 'background') {
background: map.get($theme, 'general', 'inputs', 'background');
}
@else {
background: transparent;
}
}
}

@if $theming-checkboxes {
.rx-editor #{$redactor-checkboxes-selector} {
border-color: map.get($theming-checkboxes, 'background');
background-color: map.get($theming-checkboxes, 'background');
}
}
@else {
.rx-editor #{$redactor-checkboxes-selector} {
border-color: $default-material-checkbox;
background-color: $default-material-checkbox;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
@use 'sass:map';

$material-odd-background: #F0F0F0;

@mixin row-coloring($color, $rows) {
&:nth-child(#{$rows}) {
background-color: $color;
}
}

@mixin generate-from($theme) {
$theming-rows: map.get($theme, 'tables', 'rows', 'odd-even-background');

.enigmatry-redactor-content table tr {
@if (map.get($theme, 'tables', 'rows')) {
@include row-coloring(map.get($theming-rows, 'odd'), 'odd');
@include row-coloring(map.get($theming-rows, 'even'), 'even');
}
@else {
@include row-coloring($material-odd-background, 'odd');
@include row-coloring(transparent, 'even');
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
@use 'sass:map';

@mixin generate-from($theme) {
$theming-fonts: map.get($theme, 'general', 'fonts');
$redactor-th-selector: 'thead th';

.enigmatry-redactor-content {
.rx-editor, .rx-content {
@if $theming-fonts {
$body-font-family: map.get($theming-fonts, 'body', 'family');

font: {
family: map.get($theming-fonts, 'body', 'family');
size: map.get($theming-fonts, 'body', 'size');
}
letter-spacing: map.get($theming-fonts, 'body', 'letter-spacing');

Copy link
Member

Choose a reason for hiding this comment

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

As per documentation, we have many optional combinations of settings. Please make this code flexible to be in line with our docs.

h1, h2, h3, h4 {
font-family: map.get($theming-fonts, 'hero-titles', 'family');
letter-spacing: map.get($theming-fonts, 'hero-titles', 'letter-spacing');
}

h5, h6 {
font-family: map.get($theming-fonts, 'titles', 'family');
letter-spacing: map.get($theming-fonts, 'titles', 'letter-spacing');
}

table {
font-size: map.get($theming-fonts, 'body', 'size');

#{$redactor-th-selector} {
font-size: map.get($theme, 'tables', 'header', 'font-size');
}
}
}
@else {
color: rgb(0 0 0 / .6);
font-family: 'Roboto', sans-serif;
}
}
}
}
1 change: 1 addition & 0 deletions libs/entry-components/styles/partials/theming.scss
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
@use 'core/components';
@use 'vendors/overrides';
1 change: 1 addition & 0 deletions libs/entry-components/styles/partials/vendors/_index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@use 'overrides/redactor';
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@use 'redactor';
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
$material-box-shadow: 0 3px 1px -2px rgb(0 0 0 / .2), 0 2px 2px 0 rgb(0 0 0 / .14), 0 1px 5px 0 rgb(0 0 0 / .12);
$material-box-shadow-hovered: 0 2px 4px -1px rgb(0 0 0 / .2), 0 4px 5px 0 rgb(0 0 0 / .14), 0 1px 10px 0 rgb(0 0 0 / .12);

.enigmatry-redactor-content button {
height: 36px;
margin: 8px 8px 8px 0;
padding: 0 16px;
border: none;
border-radius: 4px;
box-shadow: $material-box-shadow;
color: #FFF;
font: {
family: 'Roboto', sans-serif;
weight: 500;
size: 14px;
}

&:hover {
box-shadow: $material-box-shadow-hovered;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@use 'sass:map';

$material-text-color: rgb(0 0 0 / .87);
$material-border: rgb(0 0 0 / .38);
$material-icon-color: rgb(0 0 0 / .54);

.enigmatry-redactor-content {
.rx-editor, .rx-content {
color: $material-text-color;
}

.rx-button-icon svg {
fill: $material-icon-color;
}

.rx-main-container {
border-color: $material-border;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@use 'general';
@use 'tables';
@use 'buttons';
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
$redactor-first-row: 'tr:first-child';
$redactor-last-row: 'tr:last-child';

.enigmatry-redactor-content table {
th {
font-weight: 500;
}

#{$redactor-first-row} {
th, td {
border-top: none;
}
}

#{$redactor-last-row} td {
border-bottom: none;
}

th, td {
&:first-child {
border-left: none;
}

&:last-child {
border-right: none;
}
}
}