Bootstrap with React: accordion won't work - twitter-bootstrap-3

I am trying to get a bootstrap accordion running, where my panels are React classes. Somehow this doesn't work:
<ReactBootstrap.Accordion>
<WontWorkPanel pkey={1} />
<WontWorkPanel pkey={2} />
</ReactBootstrap.Accordion>
http://jsfiddle.net/3azxcquh/
The WontWorkPanel is React class that renders the single panel with the key this.props.pkey .
Could someone explain me what I'm doing wrong, or how to do it better?
Thanks!

The Accordion clones its children with new props, and those props control the showing/hiding of the Panel component. To allow that to still work with a custom Panel wrapper, you need to transfer props from the wrapper to the Panel child:
Fiddle: http://jsfiddle.net/ssorallen/3azxcquh/6/
var WontWorkPanel = React.createClass({
render: function() {
return this.transferPropsTo(
<ReactBootstrap.Panel header={"WontWork " + this.props.key} key={this.props.key}>
Anim pariatur cliche reprehenderit, enim eiusmod high life
accusamus terry richardson ad squid. 3 wolf moon officia aute,
non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt
laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua pu
</ReactBootstrap.Panel>
);
}
});

Related

How can I inject fonts and colour variables (fetched from backend api upon page load) into Nuxt.js styles?

I am building an application in Nuxt.js where each clients can configure custom fonts & colours depending on their brand. Clients can specify upto 3 fonts and 3 colours, which are exposed to the front-end via an api endpoint:
Fonts:
primary-font
secondary-font
tertiary-font
Colours:
primary-colour
seconday-colour
tertiary-colour
How can I inject these fonts and colours into the application when a user visits the clients link https://{client-slug}.{domain}.com ?
You can construct a FontFace object and inject it to the document.
Following are the example of how you can achieve it. You can run the code snippet:
const fontFamily = 'Sansita Swashed'; // your custom font family
const fontSrc = 'https://fonts.gstatic.com/s/sansitaswashed/v1/BXR8vFfZifTZgFlDDLgNkBydPKTt3pVCeYWqJnZSW7RpXTIfeymE.woff2' // your custom font source
function injectCustomFont() {
const customFont = new FontFace(fontFamily, `url(${fontSrc})`);
customFont.load().then((font) => {
document.fonts.add(font);
document.body.style.fontFamily = '"Sansita Swashedr", cursive';
});
}
document.getElementById('btnFontChanger').addEventListener('click', () => {
injectCustomFont();
});
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<button id="btnFontChanger" type="button">Click to change font</button>
FontFace() constructor can accept one more parameter. Learn more at here.
Note:
FontFace is still an experimental. You must double check the browser compatibility before using it.
Relatable links:
https://usefulangle.com/post/74/javascript-dynamic-font-loading
https://developer.mozilla.org/en-US/docs/Web/API/FontFace/FontFace

how do i create mdb vue tabs dynamically

I want to create a tabs pane that has a + button, and when you click it, it creates a new tab. Has anyone had experience doing this with mdb vue?
If you're using the simplest version with arrays of links and content, you need to create a button which will add additional elements to them on click event. I have encountered a problem though - adding the new tab causes a problem with calculating the height of a pane - you can fix it by adding a dynamic key to your component.
<template>
<mdb-container>
<mdb-btn floating tag="a" #click="addNewTab" icon="plus" />
<mdb-tabs
:key="activeTab"
:active="activeTab"
tabs
#activeTab="activeTab = $event"
:links="links"
:content="content"
/>
</mdb-container>
</template>
<script>
import { mdbContainer, mdbTabs, mdbBtn } from "mdbvue";
export default {
name: "TabPage",
components: {
mdbContainer,
mdbTabs,
mdbBtn
},
data() {
return {
activeTab: 0,
links: [{ text: "Home" }, { text: "Profile" }, { text: "Contact" }],
content: [
`Raw denim you probably haven't heard of them jean shorts Austin. Nesciunt tofu stumptown aliqua, retro synth master cleanse. Mustache cliche tempor, williamsburg carles vegan helvetica. Reprehenderit butcher retro keffiyeh dreamcatcher synth. Cosby sweater eu banh mi, qui irure terry richardson ex squid. Aliquip placeat salvia cillum iphone. Seitan aliquip quis cardigan american apparel, butcher voluptate nisi qui.`,
`Food truck fixie locavore, accusamus mcsweeney's marfa nulla single-origin coffee squid. Exercitation +1 labore velit, blog sartorial PBR leggings next level wes anderson artisan four loko farm-to-table craft beer twee. Qui photo booth letterpress, commodo enim craft beer mlkshk aliquip jean shorts ullamco ad vinyl cillum PBR. Homo nostrud organic, assumenda labore aesthetic magna delectus mollit. Keytar helvetica VHS salvia yr, vero magna velit sapiente labore stumptown. Vegan fanny pack odio cillum wes anderson 8-bit, sustainable jean shorts beard ut DIY ethical culpa terry richardson biodiesel. Art party scenester stumptown, tumblr butcher vero sint qui sapiente accusamus tattooed echo park.`,
`Etsy mixtape wayfarers, ethical wes anderson tofu before they sold out mcsweeney's organic lomo retro fanny pack lo-fi farm-to-table readymade. Messenger bag gentrify pitchfork tattooed craft beer, iphone skateboard locavore carles etsy salvia banksy hoodie helvetica. DIY synth PBR banksy irony. Leggings gentrify squid 8-bit cred pitchfork. Williamsburg banh mi whatever gluten-free, carles pitchfork biodiesel fixie etsy retro mlkshk vice blog. Scenester cred you probably haven't heard of them, vinyl craft beer blog stumptown. Pitchfork sustainable tofu synth chambray yr.`
]
};
},
methods: {
addNewTab() {
this.links.push({ text: "New Tab" });
this.content.push("Default content");
this.activeTab = this.links.length - 1;
}
}
};
</script>

How to change the layout of ion-slide?

I'm trying to use ion-slides:
<ion-content>
<ion-slides pager="true" [options]="slideOpts">
<ion-slide class="step-one">
<h1>Welcome</h1>
<p>Lorem ipsum dolor sit amet, massa nam ante. Vel lacus viverra volutpat tortor ligula ornare, varius ut mauris ipsum mus torquent, scelerisque suspendisse penatibus, purus et arcu ipsum vehicula quam luctus. Consectetuer sed urna accumsan. Nec viverra felis varius pretium, volutpat in et cras, odio consectetuer lacinia risus feugiat sit etiam, commodo pulvinar, dolor non et inventore.</p>
</ion-slide>
<ion-slide class="step-two">
<h1>Heading</h1>
<p>blah, blah</p>
</ion-slide>
<ion-slide class="step-three">
<h1>Heading</h1>
<p>blah, blah</p>
<ion-button (click)="end()">END</ion-button>
</ion-slide>
</ion-slides>
</ion-content>
However, I was expecting the flow of content to be top-to-bottom rather than having the "Welcome" header to the left.
I've looked at the slider layout documentation but I couldn't see how to change the layout to flow vertically down the page.
By inspecting the css in the browser debugger, I figured out that I could change the flex model and by adding the following to my page.scss it appears to fix the problem. Is there a more 'ionic' way to solve this?
.swiper-slide {
flex-direction: column;
}
Apologies if this question is very basic, I'm a data specialist so front end development is not (yet) a strength of mine.
The solution for me was to add the following css:
.swiper-slide {
flex-direction: column;
}

Enzyme computed Error - TypeError: Cannot read property 'find' of undefined

There is an error
Vue warn]: Error in render: "TypeError: Cannot read property 'find' of undefined"
when I tested my vue component. I tried different methods but still got an undefined error. When I load All meetups it is working fine. But the problem when I would like to get a signle event
store.js
state: {
loadMeetups :[
{
imageUrl: 'https://upload.wikimedia.org/wikipedia/commons/4/47/New_york_times_square-terabass.jpg',
id: 'afajfjadjaaadja323',
title: 'Meetup in New York' ,
date:'2018-07-17'
},
{
imageUrl: 'https://upload.wikimedia.org/wikipedia/commons/1/14/Palais_de_Justice_%28Paris%29_June_2010.jpg',
id: 'aadsfhbkhlk1241',
title: 'Meetup in Paris',
date:'2018-07-19'
}
],
user: {
id: 'afajfjadjaaadja323',
registeredMeetups: ['aadsfhbkhlk1241']
}
}
Meeetup.vue
<template>
<v-container>
<v-layout row wrap="">
<v-flex xs12>
<v-card>
<v-card-title>
<h3 class="primary--text">{{ meetup.id }}</h3>
</v-card-title>
<v-card-media
src="https://upload.wikimedia.org/wikipedia/commons/4/47/New_york_times_square-terabass.jpg"
height="400px"
>
</v-card-media>
<v-card-text>
<div class="info--text">17th July 2017 - Where it takes place</div>
<div>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</div>
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn class="red darken-1" dark="">Register</v-btn>
</v-card-actions>
</v-card>
</v-flex>
</v-layout>
</v-container>
</template>
<script>
export default {
props: {
id:String
},
computed:{
meetup(){
return this.$store.getters.loadedMeetup(this.id)
}
}
}
</script>
Method has to go into a getter. So once I have defined the getter, then I can use it any component in your project under, this.$store.getters. This is working with right syntax working!!
https://vuex.vuejs.org/guide/getters.html
loadedMeetup: state => (id) => {
return state.loadedMeetups.find(meetup => meetup.id === id)
}

Nested List Group in Bootstrap 4

The nested list groups in the code below work perfectly in Chrome, Edge and FireFox. However, in IE11 the nested lists don't display properly. If I use columns the text doesn't stay in the box. If I don't use columns, the text runs off the screen. Any suggestions? Thanks.
<div>
<ul class="list-group">
<li class="list-group-item">
<strong>Group 1</strong>
<ul class="list-group">
<li class="list-group-item col offset-1 col-11">Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic.</li>
<li class="list-group-item col offset-1 col-11">Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic.</li>
</ul>
</li>
<li class="list-group-item">
<strong>Group 2</strong>
<ul class="list-group">
<li class="list-group-item col offset-1 col-11">Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic.</li>
<li class="list-group-item col offset-1 col-11">Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic.</li>
</ul>
</li>
</ul>
</div>
EDIT 3-3-17
I think I might have got it working IE11 but then if failed the same way on an Apple with Safari. So, I gave up on that approach and did:
<div class="card-block">
<p>Heading</p>
<dl>
<dt>Topic 1</dt>
<dd>Item 1</dd>
<dd>Item 2</dd>
</dl>
<dl>
<dt>Topic 2</dt>
<dd>Item 1</dd>
<dd>Item 2</dd>
</dl>
</div>
This works fine everywhere. I suspect my problem may have something to do with the combination of BS4 and some CSS from a couple of other packages that I incorporated. I just ran out of time and rewrote using Card.