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

feat: create studio features announcement bar #2448

Merged
Merged
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
3 changes: 3 additions & 0 deletions cms/static/images/close-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions cms/static/images/external-link-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions cms/static/sass/_build-v1.scss
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
@import 'elements/uploaded-assets'; // layout for asset tables
@import 'elements/creative-commons';
@import 'elements/tooltip';
@import 'elements/feature-anouncement';

// +Base - Specific Views
// ====================
Expand Down
43 changes: 43 additions & 0 deletions cms/static/sass/elements/_feature-anouncement.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// studio - elements - announcement bar
// ====================================

.announcement-bar {
position: relative;
background: #03c7e8;
ruzniaievdm marked this conversation as resolved.
Show resolved Hide resolved
text-align: center;
color: $black;
padding: ($baseline*0.3) ($baseline*2.2);
font: 500 1.4rem/2rem $font-family-sans-serif;
}

.announcement-bar-link {
color: inherit;
text-decoration: underline;

&:hover,
&:focus {
color: inherit;
text-decoration: none;
}
}

.announcement-bar-icon {
display: inline-block;
vertical-align: middle;
}

.announcement-bar-close {
@include right(0);

position: absolute;
top: 50%;
transform: translateY(-50%);
background: transparent url('#{$static-path}/images/close-icon.svg') center;
width: ($baseline*1.2);
height: ($baseline*1.2);
border: none;

&:hover {
opacity: 0.7;
}
}
2 changes: 2 additions & 0 deletions cms/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@
<% online_help_token = self.online_help_token() if hasattr(self, 'online_help_token') else None %>
<%include file="widgets/header.html" args="online_help_token=online_help_token" />

<%include file="widgets/feature-announcement.html" />

<%
banner_messages = list(PageLevelMessages.user_messages(request))
%>
Expand Down
44 changes: 44 additions & 0 deletions cms/templates/widgets/feature-announcement.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<!-- Feature Announcement bar -->
<%page args="course=None" expression_filter="h" />
<%namespace name='static' file='../static_content.html'/>
<%! from django.utils.translation import gettext as _ %>

<div class="announcement-bar is-hidden">
<div class="announcement-bar-content">
${_("We’ve updated the library authoring experience with a fresh new look!")}
<a href="https://edx.readthedocs.io/projects/edx-partner-course-staff/en/latest/course_components/libraries.html"
class="announcement-bar-link"
target="_blank">${_("Learn more")}</a>
<img class="announcement-bar-icon" src="${static.url('images/external-link-icon.svg')}" alt="${_('External link icon')}">
</div>
<button type="button" class="announcement-bar-close">
<span class="sr-only">${_("Close")}</span>
</button>
</div>

<script>
var $announcementBar = $('.announcement-bar');
var onLearnMoreAnalyticEvent = 'Learn more about the Studio announcement bar';
var onCloseAnalyticEvent = 'Close the Studio announcement bar';

$.cookie('openedx-studio-announcement')
? $announcementBar.remove()
: $announcementBar.removeClass('is-hidden');

function closeBarAndFireAnalyticsEvent(message) {
$announcementBar.hide();
$.cookie('openedx-studio-announcement', 'false');

% if settings.CMS_SEGMENT_KEY:
window.analytics.track(message);
% endif
}

$('.announcement-bar-link').on('click', function () {
closeBarAndFireAnalyticsEvent(onLearnMoreAnalyticEvent);
});

$('.announcement-bar-close').on('click', function () {
closeBarAndFireAnalyticsEvent(onCloseAnalyticEvent);
});
</script>