Semantic UI Vertical Align Icon and Menu - css

I am currently trying to align a Icon and a text in a Menu.Item with Semantic UI React V.0.68.2.
Currently my HTML output looks like this:
<a class="active item pointer">
<i aria-hidden="true" class="icon ti-icon ti-home large"></i>
Dashboard
</a>
And my JSX like this:
<Menu vertical className="some classes" icon=''>
<Menu.Item
active={active}
onClick={onClick}
className="some class"
>
<Icon name="home" large /> Dashboard
</Menu.Item>
</Menu>
I wrote a new Icon component to use my own Icon Font which looks like this. I tried to stay as close to the original Icon class from the React Implementation of Semantic UI.
import React, { Component } from "react";
import classnames from "classnames";
/**
* #class Icon
* #extends {Component}
* #description Icon class for themify icons. Replacement for semantic ui Icon class
*/
class Icon extends Component {
render() {
var iconClass = classnames("icon ti-icon ti-" + this.props.name, {
big: this.props.big,
large: this.props.large,
close: this.props.close
});
return (
<i
aria-hidden={true}
className={this.props.close ? iconClass.replace("icon", "") : iconClass}
onClick={this.props.onClick}
/>
);
}
}
export default Icon;
Now I want the Text and the Icon to be vertically centered but I can't get it to work, they text always seems to be at the top of its parent node. But actually I want it to appear vertically centered in the Menu.Item. with any size of the Icon. So when I change the size of the Icon to large the text should always be centered vertically. The size classes are the same as in Semantic UI.
Does anyone have an idea how to achieve this ? Thanks in advance :)

Hi you are facing a very common problem, possible solutions are depicted in the following codepen
https://codepen.io/anon/pen/XEKZwq
What I suggest you do is to wrap the text in a span so instead of:
<a class="active item pointer">
<i aria-hidden="true" class="icon ti-icon ti-home large"></i>
Dashboard
</a>
you do the following
<a class="active item pointer">
<i aria-hidden="true" class="icon ti-icon ti-home large"></i>
<span>Dashboard</span>
</a>
Once you've done this you can easily use the solution in the codepen above.

Related

How to remove empty space in React and Bootstrap 5

I'm writing a pet project that needs to be mobile responsive and I have a problem with white space in the Carousel component, I don't know how to remove it, can someone help me?
This is looks like page on PC
https://imgur.com/a/3zwNDnl
This is looks like mobile devices https://imgur.com/a/qEwPDdC
And I want to remove the empty space at the bottom, make the carousel responsive, how can I do that?
Here is my component code
import ...
export default class CarouselBox extends Component{
render(){
return(
<Carousel>
<Carousel.Item>
<img className="d-block w-100"
src={edinburghView1}
alt="Edinburgh_Uni"
/>
<Carousel.Caption>
<Nav.Link href='/EdinburghCity'>
<h3>Edinburgh city</h3>
<p>Edinburgh city view in 2023</p>
</Nav.Link>
</Carousel.Caption>
</Carousel.Item>
)
}
}
Here is my Footer component
import { MDBFooter } from 'mdb-react-ui-kit';
export default class Footer extends Component {
render() {
return (
<>
<MDBFooter sticky="bot" bgColor='light' className='text-center text-lg-left' class="fixed-bottom">
<div className='text-center p-3' style={{
backgroundColor: '#f8f9fa',
marginTop: '0.5%' }}>
© {new Date().getFullYear()} Copyright:{' '}
<a className='text-dark' href='https://t.me/koreechdhs'>
Boiar Kostiatyn
</a>
</div>
</MDBFooter>
</>
)
}
}
I'm somewhat confused what you mean by:
I want to remove the empty space at the bottom, make the carousel responsive, how can I do that?
I'm assuming the red area here you're talking about?
That is because, you have
sticky="bot"
in:
<MDBFooter sticky="bot" bgColor='light' className='text-center text-lg-left' class="fixed-bottom">
which is doing exactly what you want.
If you want the carousel to be full height you will need to add that in the component at that viewport size, reference sizing

React Bootstrap <Button > Component Circular

There is a question just like this, but the answer wasn't very clear and I don't have enough "points" to comment on it.
I read https://react-bootstrap.github.io/components/buttons/ and some other documents but am unable to find my answer.
I used this article as my guide: https://www.pluralsight.com/guides/how-to-position-react-bootstrap-popover
import Popover from 'react-bootstrap/Popover';
import OverlayTrigger from 'react-bootstrap/OverlayTrigger';
import Button from 'react-bootstrap/Button';
.
.
.
render() {
const popover = (
<Popover id="popover-basic">
<Popover.Title as="h3">Popover title</Popover.Title>
<Popover.Content>
Popover content <strong>some strong content</strong> Normal content again
</Popover.Content>
</Popover>
);
return (
<div className='toggle container '>
<div className='form-row justify-content-center'>
<div className='col-6'>
<section class='inline-block'>
<span class="badge badge-pill badge-primary ml-2">1</span>
<h3>
Choose System Type:
</h3>
<div id="element1">
<OverlayTrigger trigger="hover" placement="right" overlay={popover}>
<Button variant="outline-primary" circle><i class="fas fa-question"></i></Button>
</OverlayTrigger>
</div>
</section>
</div>
</div>
</div>
I'd like my popover button to be a circle, but I can't find documentation on how to do that.
Can someone explicitly help me using the ? Perhaps something else? Examples help immensely. Here is a screenshot of what it looks like now...
You can set className="rounded-circle" to your button component and it will be circle.
More about similar border classes:
Bootstrap documentation

Use Three Dots span to trigger DropDown

I am using react-bootstrap, and have a button with a caret that triggers a dropdown.
But I need to use the vertical 3 dots instead, not in a button style.
I have a span that uses a CSS class for the three dots, but can't seem to find a way to get rid of the button and caret.
What I have tight now is this:
<Dropdown>
<Dropdown.Toggle>
<span className="threedots"></span>
</Dropdown.Toggle>
<Dropdown.Menu size="sm" title="">
<Dropdown.Header>Options</Dropdown.Header>
<Dropdown.Item .... ></Dropdown.Item>
</Dropdown.Menu>
</Dropdown>
I just want to see the three dots (I'll add a mouse-over effect). Is there a way to use a snap as a toggle>
You can customise Dropdown by passing in custom subcomponents. Custom Dropdown Components
const CustomToggle = React.forwardRef(({ children, onClick }, ref) => (
<a
href=""
ref={ref}
onClick={e => {
e.preventDefault();
onClick(e);
}}
>
{/* custom icon */}
{children}
</a>
));
then pass as a custom toggle
<Dropdown >
<Dropdown.Toggle as={CustomToggle}>
</Dropdown.Toggle>
<Dropdown.Menu size="sm" title="">
<Dropdown.Header>Options</Dropdown.Header>
<Dropdown.Item .... ></Dropdown.Item>
</Dropdown.Menu>
</Dropdown>
sample codesandbox,Hope be helpful

Angular accordion and popover overlay

I'm using http://angular-ui.github.io/bootstrap/ accordion and popover inside accordion.
But Popover and accordion creates overlay and popover block displays only inside accordion.
Html code:
<accordion>
<accordion-group is-open="element.hide" is-disabled="lock">
<accordion-heading>
<i class="icon-chevron-right" ng-hide="element.hide"></i>
<i class="icon-chevron-down" ng-show="element.hide"></i>
<i ng-show="element.description" popover="{{element.description}}" popover-trigger="mouseenter" class="icon-info-sign"></i>
</accordion-heading>
//inner eccordion HTML
</accordion-group>
</accordion>
It would be better if you can provide a plunkr. But i feel like "popover-append-to-body" might solve your problem.
<i ng-show="element.description" popover="{{element.description}}" popover-trigger="mouseenter" popover-append-to-body="true" class="icon-info-sign"></i>

Does jQuery Mobile provide a mechanism to extend it's theming model

I'm trying to add a custom class to the jQuery Mobile theme. The CSS should look something like this:
.ui-icon-form-ok-f {
background-color: #f09000 !important;
data-icon: check !important;
}
but how can I get jQuery Mobile to recognize this? Thanks.
How to recognize a custom icon style to jqm
For each elements of any
When you set [data-icon=AAA] on buttons, jqm creates <span class="ui-icon-AAA"> inside the buttons.
That is:
<a data-role="button" data-icon="form-ok-f">custom icon button</a>
When loads this html, jqm creates like this:
<a href="#" data-role="button" data-icon="form-ok-f" data-corners="true" data-shadow="true" data-iconshadow="true" data-wrapperels="span" data-theme="c" class="ui-btn ui-shadow ui-btn-corner-all ui-btn-icon-left ui-btn-up-c">
<span class="ui-btn-inner ui-btn-corner-all">
<span class="ui-btn-text">custom icon button</span>
<span class="ui-icon ui-icon-form-ok-f ui-icon-shadow"> </span>
</span>
</a>
So, jqm can recognize your custom-icon-class.
.ui-icon-form-ok-f {
background-color: #f09000 !important;
background-position:-252px 50% !important; /* this mean 'data-icon="check"' on css */
}​​​​
By applying this way, pages can load "ui-icon-alt"
<a data-role="button" data-icon="check ui-icon-alt">custom icon button</a>
Jqm renders Black icons (Alt icon color) instead of White icons.
For each theme of any
If you want to 'customize' icon for each theme of any, you should be loaded js like this:
$(function(){
var $alttheme = new Array( "f", "g" ); // this arr means 'data-theme="f", data-theme="g"'
var at = new Array();
for( t in $alttheme ){
at.push(':jqmData(theme="' + alttheme[t] + '"):jqmData(icon="check") > span > .ui-icon');
}
$(at.join()).addClass('ui-icon-"YOUR CUSTOM NAMES"');
});
*YOUR CUSTOM NAME (eg.form-ok, form-ng ...)
OR
$(function(){
$(':jqmData(theme="f"):jqmData(icon="check") > span > .ui-icon').addClass('ui-icon-form-ok-f');
$(':jqmData(theme="g"):jqmData(icon="check") > span > .ui-icon').addClass('ui-icon-form-ok-g');
});
The former adds the same class to icons in "theme g" and "theme f", the latter adds respectively a separate class to icons in "theme g" and "theme f".
At last
i've to prepare for some samples.
I think you should override also other classes, like .ui-bar-f, .ui-body-f, .ui-btn-up-f,... and then use the attribute data-theme="f" of each tag to specify that you want to use this new theme for the component, but I have not managed to test it.
More information is in jQuery-Mobile docs about theming.
Hope it helps!

Resources