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

Implements the remaining component library changes #8622

Merged
merged 21 commits into from
Mar 26, 2021
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
202420c
Replaces all instances of #3E00FF with #6F3FF5
gdixon Mar 18, 2021
61cf1e7
Replaces remaining .button types with .btn types
gdixon Mar 18, 2021
b10eedc
Fixes minor style bugs on landing and activity feed
gdixon Mar 18, 2021
529ae36
Fixes hackathon dashboard styles
gdixon Mar 18, 2021
a4745fe
Fixes form styles and adds error state to inputs/selects/btn-radios e…
gdixon Mar 18, 2021
d4d454d
Tidy up townsquare
gdixon Mar 22, 2021
813948b
Implements .bs-alert to replace .alert
gdixon Mar 22, 2021
0746473
Updates .nav-tabs to primary color
gdixon Mar 22, 2021
49fc853
Implements .gc-accordion design and drops jquery accordion show/hide
gdixon Mar 23, 2021
58fe1a7
Merge remote-tracking branch 'origin/master' into gpg/remaining-compo…
gdixon Mar 23, 2021
7f84454
Double quotes -> single quotes
gdixon Mar 23, 2021
7fd5a49
Cleans up styles
gdixon Mar 24, 2021
38fde32
Adds component style guide
gdixon Mar 24, 2021
2142d6b
Drops sass_experiment
gdixon Mar 24, 2021
65f096f
Fixes linting error
gdixon Mar 24, 2021
ec4bf2e
Merge branch 'master' into gpg/remaining-components
gdixon Mar 24, 2021
f9b62ed
Removes dead code
gdixon Mar 24, 2021
d709226
Merge branch 'master' into gpg/remaining-components
thelostone-mc Mar 25, 2021
c112c29
Adds third-party libraries, typography examples and color examples to…
gdixon Mar 26, 2021
45cd851
Fixes vs-select min-height and adds font-weight:bold to selected acco…
gdixon Mar 26, 2021
c25dd76
Merge remote-tracking branch 'origin/master' into gpg/remaining-compo…
gdixon Mar 26, 2021
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: 1 addition & 1 deletion app/app/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,6 @@
re_path(r'^modal/extend_issue_deadline/?', dashboard.views.extend_issue_deadline, name='extend_issue_deadline'),

# brochureware views
re_path(r'^sass_experiment/?', retail.views.sass_experiment, name='sass_experiment'),
re_path(r'^homeold/?$', retail.views.index_old, name='homeold'),
re_path(r'^home/?$', retail.views.index, name='home'),
re_path(r'^landing/?$', retail.views.index, name='landing'),
Expand All @@ -485,6 +484,7 @@
re_path(r'^activity/?', retail.views.activity, name='activity'),
re_path(r'^townsquare/?', townsquare.views.town_square, name='townsquare'),
re_path(r'^$', townsquare.views.landing_toggle, name='index'),
re_path(r'^styleguide/components/?', retail.views.styleguide_components, name='styleguide_components'),
path('action/<int:offer_id>/<slug:offer_slug>/go', townsquare.views.offer_go, name='townsquare_offer_go'),
path('action/new', townsquare.views.offer_new, name='townsquare_offer_new'),
path(
Expand Down
27 changes: 6 additions & 21 deletions app/assets/v2/js/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ $(document).ready(function() {
$top_nav_notif.parents('.row').remove();
localStorage['top_nav_notification_remove_' + top_nav_salt] = true;
};

// display (if it holds a message and hasn't been closed) or remove #top_nav_notification
if (top_nav_salt == 0 || localStorage['top_nav_notification_remove_' + top_nav_salt]) {
remove_top_row();
Expand Down Expand Up @@ -225,32 +225,17 @@ $(document).ready(function() {
$(event.target).parents('.faq_parent').find('.answer').toggleClass('show');
});


$('body').on('click', '.accordion', event => {
const element = $(event.target);
const panel = element[0].nextElementSibling;

if (panel) {
if (element.hasClass('active')) {
panel.style.maxHeight = 0;
panel.style.marginBottom = 0 + 'px';
} else {
panel.style.maxHeight = panel.scrollHeight + 'px';
panel.style.marginBottom = 10 + 'px';
}
}
element.toggleClass('active');
});
attach_close_button();
});


const attach_close_button = function() {
$('body').delegate('.alert .closebtn', 'click', function(e) {
$(this).parents('.alert').remove();
$('.alert').each(function(index) {
$('.alert').not('.alert-static').each(function(index) {
if (index == 0) $(this).css('top', 0);
else {
let new_top = (index * 66) + 'px';
let new_top = (index * 70) + 'px';

$(this).css('top', new_top);
}
Expand All @@ -277,12 +262,12 @@ const _alert = function(msg, _class, remove_after_ms) {
};
}
var numAlertsAlready = $('body > .alert:visible').length;
var top = numAlertsAlready * 44;
var top = numAlertsAlready * 70;
var id = 'msg_' + parseInt(Math.random() * 10 ** 10);

var html = function() {
return (
`<div id="${id}" class="alert ${_class} g-font-muli" style="top: ${top}px">
`<div id="${id}" class="alert alert-fixed bs-alert alert-${_class} d-flex justify-content-between align-items-center shadow-sm py-3 font-weight-semibold font-body" style="top: ${top}px">
<div class="message">
<div class="content">
${alertMessage(msg)}
Expand Down
4 changes: 0 additions & 4 deletions app/assets/v2/js/grants/_new.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,6 @@ Vue.mixin({
vm.$set(vm.errors, 'description', 'Please enter description for the grant');
}

if (!vm.$refs.formNewGrant.reportValidity()) {
return false;
}

if (Object.keys(vm.errors).length) {
return false; // there are errors the user must correct
}
Expand Down
17 changes: 6 additions & 11 deletions app/assets/v2/js/pages/quests.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ $(document).ready(function() {
const question_template = $('.form-group.question:last').clone();
const answer_template = question_template.children('span:last').clone();

let video_toggle = function(e) {
$('.select2').select2();

const video_toggle = function(e) {
var is_checked = $('#video_enabled').is(':checked');

if (is_checked) {
Expand All @@ -17,14 +19,8 @@ $(document).ready(function() {
};

$(document).on('click', '#video_enabled', video_toggle);
video_toggle();

$(document).on('form#newkudos', 'submit', function(e) {
// e.preventDefault();
// console.log($(this).formdata);
// alert('hi');

});
video_toggle();

$(document).on('click', '.add_answer', function(e) {
e.preventDefault();
Expand All @@ -37,8 +33,8 @@ $(document).ready(function() {
var last_answer = $(this).parents('.form-group.question').children('span:last');

last_answer.after(answer_template.clone());

});

$(document).on('click', '.new_quest_background', function(e) {
e.preventDefault();
$('.new_quest_background').removeClass('selected');
Expand All @@ -62,7 +58,6 @@ $(document).ready(function() {
last_question.after(question_template.clone());
});


$(document).on('click', '.close_answer', function(e) {
e.preventDefault();
if ($(this).parents('.question').find('span').length <= 1) {
Expand All @@ -73,6 +68,7 @@ $(document).ready(function() {

ele.remove();
});

$(document).on('click', '.remove', function(e) {
e.preventDefault();
$(this).parents('.form-group').find('.hidden').removeClass('hidden');
Expand All @@ -83,7 +79,6 @@ $(document).ready(function() {
$(this).remove();
});


$(document).on('click', '.close_question', function(e) {
e.preventDefault();
if ($('div.question').length <= 1) {
Expand Down
6 changes: 3 additions & 3 deletions app/assets/v2/js/pages/quests.quest.quiz_style.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ var start_quiz = async function() {
await toggle_character_class($('#protagonist'), [ 'heal', '' ]);
await toggle_character_class($('#enemy'), [ 'harm', '' ]);
}

var question_level_seconds_to_respond = response['question']['seconds_to_respond'];
var prefix = '(' + question_number + '/' + question_count + ') - ';
var question = prefix + response['question']['question'];
Expand Down Expand Up @@ -387,5 +387,5 @@ $(document).ready(function() {
if (document.quest) {
start_quest();
}
});

});
223 changes: 223 additions & 0 deletions app/assets/v2/js/pages/styleguide-components.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,223 @@
Vue.component('v-select', VueSelect.VueSelect);
Vue.use(VueQuillEditor);

const djangoExample = `{% load i18n static compress %}

...

{% compress css file example_name %}
<link rel="stylesheet" type="text/x-scss" href={% static "v2/scss/*.scss" %} />
{% endcompress %}`;

const buttonExample = '<button class="btn btn-primary">...</button>';

const inputExample = `<label for="text" class="font-caption letter-spacing text-black-60 text-uppercase">Example <span class="badge badge-greylight text-capitalize">Required</span></label>

<input id="text" name="text" v-model="form.text" class="form__input form__input-lg" maxlength="150" type="text" placeholder="Example text input" required />

<div class="text-danger" v-if="!form.text">
This is an error message
</div>`;

const selectExample = `<label class="font-caption letter-spacing text-black-60 text-uppercase" for="">Example <span class="font-smaller-6 badge badge-greylight text-capitalize ml-2">Required</span></label>

<v-select placeholder="Select option" :options="selectOptions" label="label" v-model="form.select" :reduce="option => option.name" multiple>
<template #search="{attributes, events}">
<input
class="vs__search"
:required="!form.select.length"
v-bind="attributes"
v-on="events"
/>
</template>
<template v-slot:option="option">
<span class="font-weight-semibold">[[ option.label ]]</span>
</template>
</v-select>

<div class="text-danger" v-if="!form.select.length">
This is an error message
</div>`;

const radioExample = `<span class="font-caption letter-spacing text-black-60 text-uppercase" for="">Example <span class="font-smaller-6 badge badge-greylight text-capitalize ml-2">Required</span></span>

<div class="form__radio option">
<input name="radio" v-model="form.radio" id="radio1" type="radio" value="open" val-ui="radio" required />
<label class="filter-label" for="radio1">Option 1</label>
</div>

<div class="form__radio option">
<input name="radio" v-model="form.radio" id="radio2" type="radio" value="started" val-ui="radio" required />
<label class="filter-label" for="radio2">Option 2</label>
</div>

<div class="text-danger" v-if="!form.radio">
This is an error message
</div>`;

const checkboxExample = `<span class="font-caption letter-spacing text-black-60 text-uppercase" for="">Example <span class="font-smaller-6 badge badge-greylight text-capitalize ml-2">Required</span></span>

<div class="checkbox_container">
<input name="checkbox" v-model="form.checkbox" id="checkbox" type="checkbox" value="1" required />
<span class="checkbox" ></span>
<div class="filter-label display-inline">
<label for="checkbox">Option 1</label>
</div>
</div>

<div class="text-danger" v-if="!form.checkbox">
This is an error message
</div>`;

const btnRadioExample = `<span class="font-caption letter-spacing text-black-60 text-uppercase" for="">Example 2 <span class="font-smaller-6 badge badge-greylight text-capitalize ml-2">Required</span></span>

<div :class="\`btn-group-toggle d-flex flex-column flex-lg-row flex-wrap \${!form.btnRadio ? 'invalid' : ''}\`">
<label class="btn btn-radio d-flex align-items-center justify-content-center mr-2 mb-2 font-weight-bold py-2 px-4" :class="{'active': form.btnRadio === '1'}">
<input type="radio" name="btn-radio" id="btn-radio-2-1" value="1" v-model="form.btnRadio" required>Option 1
</label>

<label class="btn btn-radio d-flex align-items-center justify-content-center mr-2 mb-2 font-weight-bold py-2 px-4" :class="{'active': form.btnRadio === '2'}">
<input type="radio" name="btn-radio" id="btn-radio-2-2" value="2" v-model="form.btnRadio" required>Option 2
</label>

<label class="btn btn-radio d-flex align-items-center justify-content-center mr-2 mb-2 font-weight-bold py-2 px-4" :class="{'active': form.btnRadio === '3'}">
<input type="radio" name="btn-radio" id="btn-radio-2-3" value="3" v-model="form.btnRadio" required>Option 3
</label>
</div>

<div class="text-danger" v-if="!form.btnRadio">
This is an error message
</div>`;

const btnCheckboxExample = `<span class="font-caption letter-spacing text-black-60 text-uppercase" for="">Example 2 <span class="font-smaller-6 badge badge-greylight text-capitalize ml-2">Required</span></span>

<div :class="\`btn-group-toggle d-flex flex-column flex-lg-row flex-wrap \${!form.btnCheckbox.length ? 'invalid' : ''}\`">
<label class="btn btn-radio d-flex align-items-center justify-content-center mr-2 mb-2 font-weight-bold py-2 px-4" :class="{'active': form.btnCheckbox.includes('1')}">
<input type="checkbox" name="btn-checkbox2-1" id="btn-checkbox-2-1" value="1" v-model="form.btnCheckbox" required>Option 1
</label>

<label class="btn btn-radio d-flex align-items-center justify-content-center mr-2 mb-2 font-weight-bold py-2 px-4" :class="{'active': form.btnCheckbox.includes('2')}">
<input type="checkbox" name="btn-checkbox2-2" id="btn-checkbox-2-2" value="2" v-model="form.btnCheckbox" required>Option 2
</label>

<label class="btn btn-radio d-flex align-items-center justify-content-center mr-2 mb-2 font-weight-bold py-2 px-4" :class="{'active': form.btnCheckbox.includes('3')}">
<input type="checkbox" name="btn-checkbox2-3" id="btn-checkbox-2-3" value="3" v-model="form.btnCheckbox" required>Option 3
</label>
</div>

<div class="text-danger" v-if="!form.btnCheckbox.length">
This is an error message
</div>`;

const richEditorExample = `<label for="rich_editor" class="font-caption letter-spacing text-black-60 text-uppercase">Example <span class="badge badge-greylight text-capitalize">Required</span></label>

<quill-editor
ref="quillEditorExample"
v-model="form.rich_editor"
:class="\`editor \${!form.rich_editor ? 'invalid' : ''}\`"
:options="editorOptionPrio"
></quill-editor>

<div class="text-danger" v-if="!form.rich_editor">
This is an error message
</div>`;

const alertExample = `<div class="alert alert-static bs-alert alert-primary d-flex justify-content-between align-items-center shadow-sm py-3 font-weight-semibold font-body">
<div class="message">
<div class="content">Message</div>
</div>
<span class="closebtn">×</span>
</div>`;

const alertExample2 = '_alert(msg, type, closeAfter);';

const accordionExample = `<div class="accordion-group gc-accordion" id="accordion-group">
<h5 class="accordion collapsed" id="headingOne" data-parent="#accordion-group" data-toggle="collapse" data-target="#collapseOne" aria-controls="collapseOne">
<span class="accordion-title">
Accordion Title 1
</span>
</h5>
<div class="accordion-panel collapse font-subheader text-grey-400" id="collapseOne" aria-labelledby="headingOne" data-parent="#accordion-group">
<p>Accordion 1 content</p>
</div>
</div>`;

const tabsExample = `<b-tabs content-class="mt-3" v-model="tabSelected" >
<b-tab :title-link-class="'nav-line'">
<template v-slot:title>Tab 1</template>
<p>Tab 1 content</p>
</b-tab>

<b-tab :title-link-class="'nav-line'">
<template v-slot:title>Tab 2</template>
<p>Tab 2 content</p>
</b-tab>
</b-tabs>`;

Vue.mixin({
methods: {
openAlert: function(type) {
_alert('Message', type);
}
}
});

if (document.getElementById('styleguide-components')) {
appFormBounty = new Vue({
delimiters: [ '[[', ']]' ],
el: '#styleguide-components',
components: {
'vue-select': 'vue-select'
},
data() {
return {
djangoExample: djangoExample,
buttonExample: buttonExample,
inputExample: inputExample,
selectExample: selectExample,
radioExample: radioExample,
checkboxExample: checkboxExample,
btnRadioExample: btnRadioExample,
btnCheckboxExample: btnCheckboxExample,
richEditorExample: richEditorExample,
alertExample: alertExample,
alertExample2: alertExample2,
accordionExample: accordionExample,
tabsExample: tabsExample,
selectOptions: [
{ 'name': 'north_america', 'label': 'North America'},
{ 'name': 'oceania', 'label': 'Oceania'},
{ 'name': 'latin_america', 'label': 'Latin America'},
{ 'name': 'europe', 'label': 'Europe'},
{ 'name': 'africa', 'label': 'Africa'},
{ 'name': 'middle_east', 'label': 'Middle East'},
{ 'name': 'india', 'label': 'India'},
{ 'name': 'east_asia', 'label': 'East Asia'},
{ 'name': 'southeast_asia', 'label': 'Southeast Asia'}
],
tabSelected: 0,
form: {
select1: [],
select2: [],
btnCheckbox: [],
btnCheckbox2: [],
rich_editor: '',
rich_editor2: ''
},
editorOptionPrio: {
modules: {
toolbar: [
[ 'bold', 'italic', 'underline' ],
[{ 'align': [] }],
[{ 'list': 'ordered'}, { 'list': 'bullet' }],
[ 'link', 'code-block' ],
['clean']
]
},
theme: 'snow',
placeholder: 'Example rich text-editor'
}
};
}
});
}
Loading