Skip to content

Commit 31f36cd

Browse files
authored
Merge pull request #228 from AvaCodeSolutions/feat/226/custom-logo
Feat/226/custom logo
2 parents 89146d0 + 931fd1c commit 31f36cd

4 files changed

Lines changed: 87 additions & 3 deletions

File tree

django_email_learning/platform/views.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,22 @@ def get_shared_context(self) -> Dict[str, Any]:
6565
and getattr(self.request.user, "has_platform_admin_role", False)
6666
)
6767
),
68+
"customLogo": {
69+
"horizontalLight": DJANGO_EMAIL_LEARNING_SETTINGS.get("LOGO", {})
70+
.get("HORIZONTAL_LOCKUP", {})
71+
.get("LIGHT_BACKGROUND"),
72+
"horizontalDark": DJANGO_EMAIL_LEARNING_SETTINGS.get("LOGO", {})
73+
.get("HORIZONTAL_LOCKUP", {})
74+
.get("DARK_BACKGROUND"),
75+
"verticalLight": DJANGO_EMAIL_LEARNING_SETTINGS.get("LOGO", {})
76+
.get("VERTICAL_LOCKUP", {})
77+
.get("LIGHT_BACKGROUND"),
78+
"verticalDark": DJANGO_EMAIL_LEARNING_SETTINGS.get("LOGO", {})
79+
.get("VERTICAL_LOCKUP", {})
80+
.get("DARK_BACKGROUND"),
81+
}
82+
if DJANGO_EMAIL_LEARNING_SETTINGS.get("LOGO")
83+
else None,
6884
"isOrganizationAdmin": (
6985
self.request.user.is_superuser
7086
or (

django_service/settings.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,16 @@
110110
"COMPONENT_TAG": "<l-helix />",
111111
}
112112
},
113+
"LOGO": {
114+
"HORIZONTAL_LOCKUP": {
115+
"LIGHT_BACKGROUND": None,
116+
"DARK_BACKGROUND": None,
117+
},
118+
"VERTICAL_LOCKUP": {
119+
"LIGHT_BACKGROUND": None,
120+
"DARK_BACKGROUND": None,
121+
},
122+
},
113123
}
114124

115125

docs/source/installation.rst

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,55 @@ The default email address for outgoing course emails. If not specified, falls ba
132132
'FROM_EMAIL': 'courses@yourdomain.com',
133133
}
134134
135+
**SIDEBAR.CUSTOM_COMPONENT**
136+
137+
Optional configuration for injecting a custom component in the platform sidebar.
138+
139+
- ``SCRIPT_URL``: URL of the JavaScript module that registers your custom element.
140+
- ``STYLE_URL``: Optional stylesheet URL for the component (use ``None`` if not needed).
141+
- ``COMPONENT_TAG``: HTML tag rendered in the sidebar.
142+
143+
.. code-block:: python
144+
145+
DJANGO_EMAIL_LEARNING = {
146+
'SITE_BASE_URL': 'https://yourdomain.com',
147+
'ENCRYPTION_SECRET_KEY': 'your-very-long-random-string',
148+
'SIDEBAR': {
149+
'CUSTOM_COMPONENT': {
150+
'SCRIPT_URL': 'url/path-to-your-component.js',
151+
'STYLE_URL': 'url/path-to-your-component.css',
152+
'COMPONENT_TAG': '<your-component />',
153+
}
154+
},
155+
}
156+
157+
**LOGO**
158+
159+
Optional configuration for branding assets in the platform header.
160+
161+
- ``HORIZONTAL_LOCKUP``: Used on mobile devices where the sidebar is not open by default and the logo is shown in the top navbar.
162+
- ``VERTICAL_LOCKUP``: Used for sidebar-oriented layouts.
163+
164+
- ``LIGHT_BACKGROUND``: Logo URL/path for light backgrounds.
165+
- ``DARK_BACKGROUND``: Logo URL/path for dark backgrounds.
166+
167+
.. code-block:: python
168+
169+
DJANGO_EMAIL_LEARNING = {
170+
'SITE_BASE_URL': 'https://yourdomain.com',
171+
'ENCRYPTION_SECRET_KEY': 'your-very-long-random-string',
172+
'LOGO': {
173+
'HORIZONTAL_LOCKUP': {
174+
'LIGHT_BACKGROUND': 'url/path-to-horizontal-logo-for-light-background.png',
175+
'DARK_BACKGROUND': 'url/path-to-horizontal-logo-for-dark-background.png',
176+
},
177+
'VERTICAL_LOCKUP': {
178+
'LIGHT_BACKGROUND': 'url/path-to-vertical-logo-for-light-background.png',
179+
'DARK_BACKGROUND': 'url/path-to-vertical-logo-for-dark-background.png',
180+
},
181+
},
182+
}
183+
135184
Email Backend Configuration
136185
---------------------------
137186

frontend/src/components/MenuBar.jsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,23 @@ function MenuBar({activeOrganizationId, changeOrganizationCallback, showOrganiza
5454
const [organizations, setOrganizations] = useState([])
5555
const [deliverContentsJobStatus, setDeliverContentsJobStatus] = useState(null)
5656
const [chip, setChip] = useState(null)
57-
const { localeMessages, isPlatformAdmin, isOrganizationAdmin, direction, apiBaseUrl, platformBaseUrl, sidebarCustomComponent } = useAppContext();
57+
const { localeMessages, isPlatformAdmin, isOrganizationAdmin, direction, apiBaseUrl, platformBaseUrl, sidebarCustomComponent, customLogo } = useAppContext();
5858

5959
const theme = useTheme();
6060
const isMdUpScreen = useMediaQuery(theme.breakpoints.up('md'));
6161

6262
const drawerVariant = isMdUpScreen ? "permanent" : "temporary";
63-
const logoHorizontalUrl = theme.palette.mode === 'light' ? logoHorizontalLightUrl : logoHorizontalDarkUrl;
64-
const logoVerticalUrl = theme.palette.mode === 'light' ? logoVerticalLightUrl : logoVerticalDarkUrl;
63+
let logoHorizontalUrl, logoVerticalUrl;
64+
if (customLogo) {
65+
logoHorizontalUrl = theme.palette.mode === 'light' ? (customLogo.horizontalLight ? customLogo.horizontalLight : customLogo.horizontalDark) : (customLogo.horizontalDark ? customLogo.horizontalDark : customLogo.horizontalLight);
66+
logoVerticalUrl = theme.palette.mode === 'light' ? (customLogo.verticalLight ? customLogo.verticalLight : customLogo.verticalDark) : (customLogo.verticalDark ? customLogo.verticalDark : customLogo.verticalLight);
67+
}
68+
if (!logoHorizontalUrl) {
69+
logoHorizontalUrl = theme.palette.mode === 'light' ? logoHorizontalLightUrl : logoHorizontalDarkUrl;
70+
}
71+
if (!logoVerticalUrl) {
72+
logoVerticalUrl = theme.palette.mode === 'light' ? logoVerticalLightUrl : logoVerticalDarkUrl;
73+
}
6574

6675
const jobsStatusMap = {
6776
"healthy": {

0 commit comments

Comments
 (0)