Is using <div class="col-sm-6"> or <b-col sm="6"> the same? - bootstrap-vue

I just started looking into bootstrap-vue (and vue actually) and I noticed that <b-col sm="6"> translates into the classic <div class="col-sm-6"> so I wonder if there is any difference or advantages in using <b-col sm="6">.
Most web designers are confortable in using <div class="col-sm-6"> so why asking them to switch to the other notation?

There is no difference but only more convenient to use.
By setting sm="6" as a property, you can more easily change the value (dynamic) without needing a jquery but purely a js function within Vue. With this you make full use of Vue which is a lot easier to see.
:sm="getColSize"
Can be anything you want. With classes i find it more effort.

<b-col> (and the other layout helper components) are purely for convenience, as they require less typing (expecially for complex colums that have different width at different breakpoints).
They are written as Vue functional components (they keep no state information), so render fast.
You can be free to mix and match with regular html markup for layout, or not use them at all.

Related

Wagtail. Ability to edit html within editor

My editors want to have an ability to edit raw html within editor.
For example, we can have simple list markup:
<ul>
<li>Some text<li>
</ul>
Or with custom classes and event tags:
<ul>
<li class="my_class">Some text
<span class="special">Some additional info</span>
<li>
</ul>
And so on.
I know that built-in Draftail doesnt support html editing.
But using third-party editor comes with problem:
Losing integration with system. For example, i cant just put image like with draftail. Or, preview mode cant handle all functionality of third-party editor.
So, maybe someone has working solution for this situation.
I thought about using special StreamField panels, but it seems to be overhead of blocks. Dont like this idea of having lots of blocks with little differences
Wagtail does not support raw HTML editing within the page editor out of the box intentionally. The philosophy (zen) of Wagtail is to help editors and developers 'wear the right hat' when working in Wagtail.
HTML editing is usually best provided to developers, where there is an expected knowledge of what is required for things like accessibility, security and the benefit of tooling (like git).
However, if HTML editing is a must, you will probably need to build your own editor field for that purpose or find a suitable package that works with HTML markup such as django-markupfield. Adding image/snippet/page chooser functionality however will have to be built for whatever you end up using. You may also want to look at the Wagtail markdown package either as an alternative to HTML or a starting point, it allows for a syntax of linking to pages/images.
Wagtail lets you use any kind of Django field or widget with the FieldPanel.
Please ensure you consider all the risks when implementing this feature, such as accessible HTML (e.g. heading levels), security (disallow some tags such as script tags), malformed HTML leaking into the rendered template and of course the end user experience.
At the end i made my own solution
Simple rewrite some methods in wagtail`s Html DbWhiteLister and HtmlConverter.
This gives me an opportunity to allow any tags with any attributes.
https://github.com/Chenger1/wagtailtinymce.-Full-Rich-Text-Editor

Is material-ui friendly to form?

Recently, when I use React&material-ui to make a form, I find that many components do not have 'name' property, such as 'SelectField'. So I must get the value through a method. Is material-ui suitable for implementing a form? If the answer is yes, can you give me a intact example which uses some components such as 'TextField', 'SelectField', and how do I submit it?
I could recommend connectin material-ui with redux-form:
http://redux-form.com/6.8.0/examples/material-ui/
Works fine as long as you pass component representing material-ui form into the Field from react redux
import { Field } from 'redux-form/immutable';
import TextField from 'material-ui/TextField';
<Field
name="username"
id="username"
type="text"
placeholder="Username"
label="Username"
required
iconName="person"
component={TextField}
/>
And then you would have form values existing in redux state.
This actually is not a material-ui specific issue i believe. You'll be in the same boat if you use simple <input> elements.
Basically what you want to do is get/set the value of a text box / checkbox when a user does some action or clicks submit. Material-ui just lets you do pretty, reusable and designed components so that you wont have to write them yourself.
To work easily with forms you would have do some additional coding from your side. I also suggest the great library redux-form but it would require you to also implement redux in your app (A great thing by itself but i dont know what are your requirements).
If you want another option then you can use https://github.com/christianalfoni/formsy-react which is another great and popular library for managing forms and doesnt require redux
If you want to do things yourself then you can use recommendations from https://facebook.github.io/react/docs/forms.html which in general tell you to have controlled components.
One final thing. Dont be afraid to use additional libraries and modules. The whole point in having hundreds thousands of modules is for people to use them =]

Integrate Htmls into GWT

We have a web application that its UI is based on GWT.
We are pretty satisfied from the technology, but we have one major problem: We get html files from our designer, and it takes a lot of time to integrate them into our GWT code.
Is there a quick way or rules to do that?
For instance, I would like to take the html, put it almost "as is" in a ui.xml file, and then start binding the components to UiBinder fields.
What is the quickest way to do that? What should I do with the CSS and JS files that I get?
I need some guidelines to make this conversion, so it will be quick & easy.
We have the same problem. It might be hard for a designer to get used to GWT widgets. But he'll have to forget about making HTML proof-of-concepts and using GWT directly.
We didn't overcame the difficulty. As a result, many GWT features are under-used (like CSSResources, or GWT-Bootstrap layout capabilities).
I would advise to have him learn the xml of GWT widget libraries.
You can also start by using GWT Designer. This way he can still do the design, learn the XML bit by bit, and you can still work on wiring the components.
Of course it is a slow process. People don't change old habits instantly.
Errai seems to fit your requirements.
Basically is uses regular HTML5 templates, binded to GWT logic.
"Create standard conform HTML5 templates or use existing HTML and CSS files to design your web and mobile applications."
http://errai.github.io/
Here is an example of a sign-in page:
<!DOCTYPE html>
<link rel=stylesheet href="css/TodoList.css">
<div data-field="main">
<h1>Get it done with Errai.</h1>
<div class=form>
<p class=error data-field=loginError>
Login failed. Please check that your email address and password were entered correctly.
</p>
<input type=text data-field=username placeholder="Email">
<input type=password data-field=password placeholder="Password">
<button data-field=loginButton>Sign In</button>
<p>New here? Sign up in seconds!</p>
</div>
</div>
source
(p.s. I've never used it, yet)

Use own tags instead of divs

I working on a web app. Is it good to use own html tags than divs? I mean using own tags instead of classes. This will make it easier to bind up dynamic content by splitting up common classes with id.
Example
<div id="message">
My Message
</div>
Replace with this
<message>
My message
</message>
I don't understand why you want this, because now HTML5 supports a lot of semantic tags like <audio>, <address>, etc. Usually, you can achive block-effect (i.e. combining or grouping related content in a block) by <div class="myblock"></div> for special purposes. Anyway, as you've asked, then for your information—you can use custom tags in HTML. Also you can style those using CSS and can use selectors to perform operation on those using JavaScript.
Note: Prior IE9 versions don't support custom tags. Hence you should create your tags like this using JavaScript:
<script type="text/javascript">
document.createElement('mytag');
</script>
The main practical reason for not doing this is that IE 8 and older do not let you style your custom tags. As Vishal mentions, there’s a workaround to this, but it does not work when JavaScript is disabled. And as he points out, you can use the class attribute—you should use id only for uniquely identifying a single element.
You can also use class attributes for elements other than div. You can first select an element so that its default (non-CSS) rendering is the best possible (among available alternatives), then add a class attribute.
In CSS, you would then normally use a class selector without tag name, e.g. .message (if you use class=message).

How to get Facebook comments count in HTML5 without using a <div>?

The Facebook comments count can be done in three different ways: (without directly using JS)
<fb:comments-count href="http://example.com" />
<iframe src="http://www.facebook.com/plugins/comments.php?href=example.com" />
<div class="fb-comments-count" data-href="http://example.com">0</div>
The issue, however, is that doing something like this messes things up:
<p><div class="fb-comments-count" data-href="http://example.com">0</div> comments</p>
...because a <div> is firstly, not valid inside a <p> tag and secondly, looks wrong (though this could be fixed with CSS).
Basically, my question is: is there a way to do the above without using a <div> (a <span> for example), bearing in mind that I want to use the HTML5 method and (if possible!) want to avoid using javascript?
Clarification: I would like to avoid writing extra JS in the page simply because the MVC view currently looks nice and clean and I would prefer to keep it that way. Obviously, I'm still including the Facebook Connect library.
So, one solution would be to use a DIV instead of a P as the outer element.