adding w-40 class in react-bootstrap - react-bootstrap

I would like to make w-40 class works with react-bootstrap. I thought that editing '_utilities.scss' in bootstrap/scss file should work but it is not. Here is the change I made:
"width": (
property: width,
class: w,
values: (
25: 25%,
50: 50%,
75: 75%,
40: 40%,
100: 100%,
auto: auto
)
),
Do you know if it is possible that way ? What should I do ?

Related

Vuetify 3: How to define button font size based on button size?

I have created settings.scss, and I have achieved to set button size with this
$typography: ('button': ('size': 14px))
and with this
$button-font-size: 14px,
But what should I do to have font size different for different button sizes?
PS. In Vuetify 2 I have used this
$btn-font-sizes: (
'small': 13px,
'large': 14px,
);
The SASS now uses a relative scaling function for button height, font-size, width-ratio, padding-ratio based off the default button size settings. With this setup you can can achieve a relative scaling of button size related CSS props using settings.$size-scales:
In your settings.scss:
#forward 'vuetify/settings' with (
$size-scales: (
'x-small': -0.7,
'small': -0.2,
'default': 0,
'large': 2,
'x-large': 10
)
);
The advantage to this approach is convenience, and that you can easily add custom sizes like xx-small or whatever. However, if you only want to change font-size and not other properties you have to target each button size in CSS:
.v-btn--size-x-small {
font-size: 8px;
}
Of course, you can use the class names to target any property of buttons and avoid the settings altogether.

KIVY Text within label

Trying to place text within a Rectangle. I even tried solution given here.
I want the text to be within Rectangle. This should holds good even if I change window size please. When I add_widget Actor I still want to continue pos_hint and size_hint format. Any idea please..
from kivy.uix.label import Label
from kivy.uix.relativelayout import RelativeLayout
from kivy.properties import ListProperty
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.scatter import Scatter
from kivy.core.window import Window
Window.clearcolor = (1, 1, 1, 1)
Window.size = (800, 600)
kv = '''
<Actor>:
canvas:
PushMatrix
Color:
rgba: 0,1,0,.8
Rectangle:
id: _rect_
size: self.width, self.height/12
pos: 0, 11 * (self.height / 12)
Line:
points: self.width/2, 11 * self.height/12, self.width/2, 0
width:2
PopMatrix
Label:
id: _actr_lbl
text: 'Hello World'
markup: True
color: 0,0,0,1
pos: 0, 11 * self.height/12
halign: 'center'
'''
Builder.load_string(kv)
class Actor(Scatter):
def __init__(self, **kwargs) :
super(Actor, self).__init__(**kwargs)
class TestApp(App):
def build(self):
layout = RelativeLayout()
layout.add_widget(Actor(pos_hint = {'center_x':0.5, 'top':0.95}, size_hint = (0.2, 1)))
return layout
if __name__ == '__main__':
TestApp().run()
I think you can accomplish what you want by adjusting your kv for the Label slightly:
Label:
id: _actr_lbl
text: 'Hello World'
markup: True
color: 0,0,0,1
size_hint: None, None
size: root.width, root.height/12
pos: 0, 11 * root.height/12
halign: 'center'
Adding size_hint: None, None allows the size to be effective. And referencing root for size and pos info keeps the Label sized and positioned correctly.

How do you set a custom susy layout's gutters to 0?

I'm finding myself frequently having to negate gutters with margin-left: 0; margin-right: 0;. I tried setting gutters in a custom layout to 0
$my_layout: (gutters: 0);
.my_class {
#include with-layout($my_layout) {
...
}
}
but this does not set the gutter width to 0, it just tells susy not set gutters at all.
How do you set gutters to 0 in a susy layout (instead of just setting them to null)?
This seems to work:
$my-layout: (
gutter-override: 0%,
);
gutter-override is generally for overriding gutters on-the-fly, but Susy allows it to be set globally as well. Currently Susy ignores gutter output of 0, but seems to allow gutter output of 0% (or 0 with any other unit).
I'd be willing to consider adding more clear null vs. 0 functionality, if you want to file an issue on github.

Gutter widths in Susy 2

In beta 2 of Susy 2, is it possible to set gutter widths in the main grid settings like so:?
$susy: (
flow: ltr,
math: static,
output: float,
gutter-position: after,
container: auto,
container-position: center,
columns: 12,
gutters: .25,
!!!!gutter-override: 20px,!!!!
column-width: 77.5px,
global-box-sizing: border-box,
last-flow: to,
debug: (
image: hide,
color: rgba(#66f, .25),
output: background,
toggle: top right,
),
);
Because it doesn't seem to like it. I need to set explicit widths for columns and gutters for this grid and the container should be determined from those.
In Susy Next, gutters are set as a ratio (.25) to the column-width (77.5px). Given those settings, Susy can determine the gutter-width (77.5px * .25 = 19.375px).
By saying you want static math, .25 gutters, and 77.5px columns, you have already set the gutter width, and the container can already be calculated. If you like, you can use real pixel values to set your gutter ratio:
$susy: (
column-width: 77.5px,
gutters: 20px/77.5px, // same as ".258064516"
);
Gutter-override is not a global setting, and won't help you here. That setting is only for spans, when you want to override the global value. Also, I don't recommend sub-pixel settings. Pixels don't really break down, and fractional pixel declarations aren't handled the same across browsers.

Adding a label or text to an ellipse object in kivy

I'd like to draw the x,y coordinates of a nested ellipse I have within the ellipse. However, I'm afraid I don't understand the object hierarchy enough for how to do that. I have tried adding a label event to be a child of the Ellipse, and I know it doesn't have a 'text' attribute that I can modify directly (as it's not a Button or a Label). Here's what I have:
MyWidget:
canvas.before:
Color:
rgba: 1,0,0,1
Ellipse:
size: min(self.size)*0.2, min(self.size)*0.2
pos: (self.x), (self.y)
Label:
text: unicode(self.x), unicode(self.y)
Error:
>> 40: Label:
41: text: unicode(self.x), unicode(self.y)
...
You can add only graphics Instruction in canvas.
So, I add it to a child of the Ellipse:
MyWidget:
canvas.before:
Color:
rgba: 1,0,0,1
Ellipse:
size: min(self.size)*0.2, min(self.size)*0.2
pos: (self.x), (self.y)
Label:
text: unicode(self.x), unicode(self.y)
>> 40: Label:
41: text: unicode(self.x), unicode(self.y)
...
You can add only graphics Instruction in canvas.
So, I try to put it in a canvas:
MyWidget:
canvas.before:
Color:
rgba: 1,0,0,1
Ellipse:
size: min(self.size)*0.2, min(self.size)*0.2
pos: (self.x), (self.y)
canvas:
Label:
text: unicode(self.x), unicode(self.y)
That doesn't have an error, but doesn't display any text.
Updating to address excellent answer below
MyWidget:
canvas.before:
Color:
rgba: 1,0,0,1
Ellipse:
size: min(self.size)*0.2, min(self.size)*0.2
pos: (self.x, self.y)
Label:
pos: (self.x,self.y)
size: min(self.size)*0.2, min(self.size)*0.2
text: "{},{}".format(str(self.x),str(self.y))
Gives me the following error:
44: Label:
>> 45: pos: (self.x, self.y)
46: size: min(self.size)*0.2, min(self.size)*0.2
47: text: "{},{}".format(str(self.x),str(self.y))
...
RuntimeError: maximum recursion depth exceeded while calling a Python object
I still can't get the text to appear /inside/ the Ellipse.
Your problem is that you cannot mix the canvas with widgets.
A way to think of it is that each widget has a canvas. You can draw what you like on that canvas, but the keyword there is draw - you can use kivy graphics instructions, like Ellipse or Rectangle or Line (or contextual instructions like Translate and Rotate). However, you can't use widgets. They don't work that way, they aren't things you draw on a canvas, they are widgets. When you add one widget to another with add_widget, one thing that happens is that its canvas is drawn on the canvas of the other, but this is kept to the canvases - it doesn't make sense to try and draw a whole widget on a canvas.
This is the root of all of your errors; Ellipse is not a widget. It doesn't have a canvas, it's only something you draw on a canvas. It can't have children because it isn't a widget. In kv language, the keyword canvas (and canvas.before etc.) doesn't mean there's a child widget called canvas, it's just a special syntax referring to the canvas of the parent widget.
So, to actually fix your problem, you need to take the Label out of the canvas. Something like the following should work:
MyWidget:
canvas.before:
Color:
rgba: 1,0,0,1
Ellipse:
size: min(self.size)*0.2, min(self.size)*0.2
pos: (self.x), (self.y)
Label:
pos: root.pos
size: min(self.size)*0.2, min(self.size)*0.2
text: unicode(self.x), unicode(self.y)
This is of course the normal syntax for making the Label just be a child of MyWidget. The important part is it's been given the same position and size as the ellipse so, since text is centered by default, the text will appear in the middle of the ellipse. If the text is long or something you might want to play with other things like setting text_size to automatically wrap, but that's a different problem.
Also, once you have multiple widgets with the same size description (like the size of both the Label and Ellipse in my example), it's often neater to move that calculation to a different place - for instance a NumericProperty of MyWidget. That way you can avoid code duplication, and also make it so that if you ever change the positioning requirements you can easily update both the Label and Ellipse simultaneously.

Resources