Google App Maker - How to keep constant space between the label and input of a dropdown/textbox widget? - google-app-maker

I have a field in a form with label/display name:
"I can confirm that this supply is not subject to restrictions under the Test Group, or be of a specialist nature, and as such require other checks that this method does not support."
I am using a dropdown widget with options Yes and No to display it.
I could wrap the label by trying below css.
.app-AddRequest-Field15-Label {
white-space: normal;
}
But now the space between the input and label is very less. Even if I put a margin top to the input when in mobile view the label wraps even more and the space still remains very less/ both override.
Images with borders
Label border: black
Input border: Orange
I want to keep a constant space in all views. Please suggest.

I mocked up a solution that works for up to four lines of data in a label. These are the steps you need to follow:
1.) In the global css, make sure you have the following lines:
.app-Dropdown-Label {
white-space: normal;
}
.twoLinesLabel{
top: -15px !important;
}
.threeLinesLabel{
top: -30px !important;
}
.fourLinesLabel{
top: -45px !important;
}
2.) On any of the client scripts place the following:
function adjustLabel(widget){
var label = widget.getElement().children[0];
var ch = label.clientHeight;
var lines = Math.floor(ch / 15);
switch(lines){
case 2:
label.classList.add("twoLinesLabel");
break;
case 3:
label.classList.add("threeLinesLabel");
break;
case 4:
label.classList.add("fourLinesLabel");
break;
}
}
3.) On the onAttach event handler of any dropdwon you need this adjustment, place the following:
adjustLabel(widget);
The only problem with that approach is that in the UI you won't be able to see the necessary space your field requires so that it don't overflows with the previous field. So you'll have to preview the app and make adjustements accordingly.
Another way is to make sure that your CSS looks like this instead:
.app-Dropdown-Label {
white-space: normal;
}
.twoLinesLabel label{
top: -15px !important;
}
.threeLinesLabel label{
top: -30px !important;
}
.fourLinesLabel label{
top: -45px !important;
}
Then on the Display category of the property editor, simply add the correspoding style to the dropdown. That way you will be able to see the changes in the editor immediately.
Whatever way you choose, the result is the following:

Related

Contact Form 7 - How Do I Style The Select Arrow and Select Options

I'm building a website using Contact Form 7 for WordPress and am having issues styling the select menu. Specifically, I cannot move the arrows or add padding to the dropdown so it's not so tight.
I've tried using this CSS to add spacing to the dropdown items (and some other CSS trickery) but it has no effect:
options {
padding: 20px 10px!important;
margin: 20px 10px!important;
line-height: 36px!important;
border-bottom: 10px solid tan!important;
}
Do you know if there's a way to control the styling behavior of CF7's select menu (arrow and options dropdown)?
Thank you!
Demo Website:
https://miles.birdhouse-demos.com/connect/
CSS styling for <select/> fields is very limited and does not allow you to achieve this. You will need to use a hybrid field plugin that constructs dropdowns with HTML lists that can be styled, such the Hybrid HTML Dropdown plugin, which can be styled and can be loaded on your page to convert your existing <select/> fields into hybrid ones,
<script type="text/javascript">
(function(){
let sel, hyd;
document.addEventListener('DOMContentLoaded', (e) => { //instantiate on document ready.
sel= document.querySelector('#my-select-list');
hyd = new HybridDropdown(sel,{});
})
})
</script>
Alternatively, you can install the Smart Grid-layout extension for CF7 which has a dynamic-dropdown field tag you can use instead of the CF7's default dropdown, and has as the option to display as a Hybrid Dropdown field for you.
Try this
It's possible to customize the dropdown arrow with this code:
select {
-webkit-appearance: none;
-moz-appearance: none;
background: url(http://cdn1.iconfinder.com/data/icons/cc_mono_icon_set/blacks/16x16/br_down.png);
background-repeat: no-repeat;
background-position-x: 98%;
background-position-y: 2px;
}
Here is a list about what you can do with this code:
Remove completely the arrow, to do so, simply remove this line: "background: url(http://cdn1.iconfinder.com/data/icons/cc_mono_icon_set/blacks/16x16/br_down.png);"
Customize the arrow size. You need to add the following line to the code given above: background-size: 30px 30px;
You can change the value in px.
Change the arrow, to do so, replace the URL in the following line of code: "background: url(http://cdn1.iconfinder.com/data/icons/cc_mono_icon_set/blacks/16x16/br_down.png);"
This guide will help you to inject the code: https://www.jotform.com/help/117-How-to-Inject-Custom-CSS-Codes
If you have any questions, let me know.
Thanks.
Credit: Kevin - From: https://www.jotform.com/answers/2449062-how-can-i-remove-modify-change-the-dropdown-arrow-using-css

Selector alignment in CSS source code

I'm looking to see if anyone has ever had any experience with this CSS syntax debate we are currently having on our team. Our dev team has been using the vim plugin Tabular to align text in our code. For example in PHP or Javascript we will align variable declarations using the plugin like this:
$count = 0;
$var_1 = array();
$var_2_long_name = array();
$stdout = fopen( 'php://stdout', 'w' );
$some_data = json_decode( $some_json_data, true );
Helps the code look clean and easy to read.
We have considered using alignment in our CSS (we are using LESS but this question could be applied to SASS or just straight CSS). For example we would change this block:
.btn-section {
position: relative;
top: -65px;
display: block;
z-index: 100;
.content-box;
background-color: #grayButton;
color: #gray;
padding: 10px 0;
.border-radius(5px);
}
To this:
.btn-section {
position : relative;
top : -65px;
display : block;
z-index : 100;
background-color : #grayButton;
color : #gray;
padding : 10px 0;
.content-box;
.border-radius(5px);
}
One of the devs experimenting with this tactic moved the mixins from their original spots to the bottom of the declaration in order to make the code "look right" since mixins don't conform the the normal selector: value; format of regular css. In this case, the .content-box mixin had a background-color declaration that was being overridden by the backgroud-color line beneath it. Moving the mixin to the bottom broke the override and gave the element the wrong background color.
Errors like this coupled with the extra steps it takes to format every single block of CSS make me think this might not be such a good idea. Has anyone ever tried this type of alignment before? Any opinions on whether this is a good or bad idea? Thanks.
I think your alignment tactic is a good idea, I'd just recommend turning it upside down:
.btn-section {
.content-box;
.border-radius(5px);
position : relative;
top : -65px;
display : block;
z-index : 100;
background-color : #grayButton;
color : #gray;
padding : 10px 0;
}
That way the more general mixin styles would be applied first, after which they may be overridden by selection specific adjustments instead of the other way around.
By doing it like this, you eliminate this risk of accidently overriding specific styles with inherited ones and still keep everything neat and easy to read.

Less if string is not empty conditional logic

I'm using dotless to dynamically change the look of my site from an admin page.
Essentially I use regular expressions to read the variables defined in the less and then give the user the option to change the value of the variables.
I'm wanting to have the option to set a background image. Essentially I need a way to check if the string is empty if its not then add the background image mixin.
#BackgroundImage: '';
.showBackground(#fileName) when (#fileName != '') {
background-image: url('../Themes/images/backgrounds/#{fileName}');
}
body {
.showBackground(#BackgroundImage)
}
So the default is no background '' when the user sets a background the variable #BackgroundImage will be set to 'backgroundImage1.jpg'
How can I get this empty string logic to work?
P.S I've tried setting the variable to #000000 and using isstring() but it would appear to return true.
You want to use the when not instead of negating the condition.
LESS
.showBackground(#fileName) when not (#fileName = '') {
background-image: url('../Themes/images/backgrounds/#{fileName}');
}
Output
#BackgroundImage: ''; // No output.
#BackgroundImage: 'foo'; // background-image: url('../Themes/images/backgrounds/foo');
Here's another possible solution that sets defaults and checks for use cases when the variable is not used. The problem it attempts to solve is using text as an indicator in some cases and a background image in others.
This worked out well enough even if there is some duplication. Your mileage may vary.
.pointer( #ico ) when not ( #ico ) {
&:extend(.global-sprite-image);
.sprite-position(#ico);
.sprite-height(#ico);
.sprite-width(#ico);
content: '';
margin-left: 2px;
line-height: 1;
}
.pointer( #ico:'›') when ( default() ) {
content: #ico;
font-size: 130%;
font-weight: bold;
font-family: #font-title;
padding-left: 2px;
line-height: 1;
}

Replacing the Close icon for a JQueryUI Dialog box

After extensive searching on this topic, I haven't been able to find an answer, so hopefully someone can help me with this issue. I have a relatively basic dialog box:
$("#dialog-search").dialog({
resizable: false,
height:dimensionData.height,
width: dimensionData.width,
modal: true,
title: dimensionData.title,
position: [x,y],
open: function() {
$("#dialog-search .dateField").blur();
},
close: function(event, ui){
callBack(event,ui);
}
});
What I want to do is replace the X icon (ui-icon-close) with a different icon provided by the ui (ui-icon-minus), so that clicking the minus icon closes the dialog instead. I've seen posts on how to hide the icon or replace it with a custom image in css, but I haven't yet found a way to replace the icon with another icon to perform the same functionality.
Edit: I also want to be able to use ui-icon-close for a different functionality in my dialog box by adding a custom behavior/location, but that may be outside the scope for this question. Feel free to address this if it's a related solution, though.
Try to see the structure of the dialog and it should not be hard to do it.
http://jqueryui.com/demos/dialog/#theming
Use the create event to change the class of the close button icon to class of another icon will do.
http://jsfiddle.net/Quincy/kHU2M/1/
$("#dialog-search").dialog({
create: function(event, ui) {
var widget = $(this).dialog("widget");
$(".ui-dialog-titlebar-close span", widget)
.removeClass("ui-icon-closethick")
.addClass("ui-icon-minusthick");
}
});
Old question, but maybe I'll help someone. Following CSS made the trick for me, totally custom Close button UI. Not very elegant :), but works fine for me.
.ui-icon-closethick {
background-image: url(images/my-10px-image.png) !important;
background-position: left top !important;
margin: 0 !important;
}
.ui-dialog .ui-dialog-titlebar-close, .ui-icon-closethick {
width: 10px !important;
height: 10px !important;
}
.ui-dialog .ui-dialog-titlebar-close {
background: none !important;
border: none !important;
}
.ui-dialog .ui-dialog-titlebar-close, .ui-dialog .ui-dialog-titlebar-close:hover {
padding: 0 !important;
}
My custom close button shown below:

Background position and repeating

I'm trying to create faked transparent form fields that "show through" to the background which is a tiled image (which of course are "showing" through the numerous divs between the inputs and the page background). Here's where I'm at:
div#searchbox, div#mailing_list ul li.fields,div#product div.info input.text {
border:1px solid #707070;
background:url(../_images/fade_bg.jpg) 0 0 repeat;
}
input#search {
background-position:-715px -163px;
}
input#name {
background-position:-134px -888px;
}
input#duhlyh-duhlyh {
background-position:-134px -926px;
}
Now, this works as expected except the background position property isn't doing anything. I can remove them, change them, nothing happens. I'm guessing that it has something to do with the fact it's a repeating background. The position values are the element offsets from the body where the background itself starts. Any way to line these up?
inputs are very hard to style using css.
However, what you could try (works in Firefox) is to remove the background image from the inputs and give them a background:transparent so that the background of the parent shows through.
Try using CSS nesting for this code
input#search {
background-position:-715px -163px;
}
input#name {
background-position:-134px -888px;
}
input#duhlyh-duhlyh {
background-position:-134px -926px;
}
with their respective parent elements because sometimes what happens is some properties are overwritten. in that case you can use css nesting and make it work

Resources