import "./styles.css";
import { Popover } from "antd";
import { FullScreen, useFullScreenHandle } from "react-full-screen";
export default function App() {
const handle = useFullScreenHandle();
return (
<div className="App">
<FullScreen handle={handle}>
<div className="App__inner">
<h1>Hello CodeSandbox</h1>
<button onClick={handle.enter}>Click to FullScreen</button>
<Popover placement="right" content={<span>tooltip</span>}>
<button>hover me</button>
</Popover>
</div>
</FullScreen>
</div>
);
}
The problem is Popover doesnt work when i make App__inner component fullscreen. I have reproduced the issue here codesandbox. Please suggest any fix or alternatives
I was expecting the Popover to work as expected in fullscreen mode
The default behavior of Popover is to create a div element in body , so when you do fullscreen the div is hidden. What you need to do is make use of getPopupContainer API of Popover and set the container body inside FullScreen for your Popover to be visible.
import "./styles.css";
import React from "react"
import { Popover } from "antd";
import { FullScreen, useFullScreenHandle } from "react-full-screen";
export default function App() {
const handle = useFullScreenHandle();
const containerRef = React.useRef(null);
return (
<div className="App" >
<FullScreen handle={handle}>
<div className="App__inner" ref={containerRef}>
<h1>Hello CodeSandbox</h1>
<button onClick={handle.enter}>Click to FullScreen</button>
<Popover getPopupContainer={() => containerRef.current} placement="right" content={<span>tooltip</span>}>
<button>hover me</button>
</Popover>
</div>
</FullScreen>
</div>
);
}
Related
I am using #radix-ui/react-dropdown-menu with my Button component inside the Trigger (with asChild prop) and the dropdown content is displayed incorrectly (if I replace Button with the html button, the content is displayed normally).
For some reason the dropdown content css is like this transform: translate3d(0px, -200%, 0px) when I am using my Button component, but when I used the html button everything works fine
import * as React from "react";
import * as DropdownMenu from "#radix-ui/react-dropdown-menu";
const Button = (props) => {
return <button {...props} />;
};
export function App() {
return (
<div className="App">
<div>
<DropdownMenu.Root>
<DropdownMenu.Trigger asChild>
<Button type="button">test 1</Button>
{/* <button type="button">test 2</button> */}
</DropdownMenu.Trigger>
<DropdownMenu.Content>
<DropdownMenu.Item>menu item</DropdownMenu.Item>
<DropdownMenu.Item>menu item</DropdownMenu.Item>
<DropdownMenu.Item>menu item</DropdownMenu.Item>
</DropdownMenu.Content>
</DropdownMenu.Root>
</div>
</div>
);
}
I've got a problem about mui Drawers. As I see on the internet, drawer never removes the content of the page, but in my case yes it does :( Can you help me to figure out what is the problem?
here is my Drawer component code:
import Drawer from '#mui/material/Drawer';
import { useState } from 'react';
import Box from "#mui/material/Box";
export default function SideBar() {
const [isDrawerOpen, setDrawerOpen] = useState(false);
return (
<div>
<button onClick={() => setDrawerOpen(true)}>left</button>
<Drawer
anchor="right"
open={isDrawerOpen}
onClose={() => setDrawerOpen(false)}
>
<Box>sdfsd</Box>
</Drawer>
</div>
)
;
}
And I call it on this page.
import Drawer from "../components/SideBar"
export default function ShopSingle(){
<div>
{/* <Navbar></Navbar>
<HeaderHome></HeaderHome> */}
<div>
PAGE CONTENT
<Drawer></Drawer>
</div>
{/* <Footer></Footer> */}
</div>
}
I'm pretty new with React, can you help me the solve problem?
hope you all doing well, i am very new in react and i was following the guide, but got stuck with this strange problem while I import { Button} from './Button'. Ill provide the full code :
import React from 'react';
import '../App.css';
import { Button } from './Button';
import './HeroSection.css';
function HeroSection() {
return (
<div className='hero-container'>
<div className="hero-btns">
<Button
className='btns'
buttonStyle='btn--outline'
buttonSize='btn--large'>Get Started</Button>
<Button
className='btns'
buttonStyle='btn--primary'
buttonSize='btn--large'>Checkout Events
<i className='far fa-play-circle' /></Button>
</div>
</div>
)
}
export default HeroSection
Here is a Button.js code also:
import React from 'react';
import './Button.css';
import {Link} from 'react-router-dom';
const STYLES= ['btn--primary', 'btn--outline'];
const SIZES= ['btn--medium', 'btn--large'];
export const Buttom =({children, type, onClick, buttonStyle,
buttonSize}) => {const checkButtonStyle=
STYLES.includes(buttonStyle) ? buttonStyle : STYLES[0]
const checkButtonSize = SIZES.includes(buttonSize) ? buttonSize :
SIZES[0]
return(
<Link to='/Login' className='btn-mobile'>
<button
className={`btn ${checkButtonStyle} ${checkButtonSize}`}
onClick={onClick}
type={type}
>
{children}
</button>
</Link>
)
};
Already Tried to put Button without {}, and tired to export default Button but it didn't fixed it at all :(
if the above is the exact Button.js file you've used
then it's just a typo, change Buttom to Button at line 7, and you're good to go
Apart from that, you can simply export the Button as default
By adding this line
export default Button;
then you'll have to import it like
import Button from './Button';
I made a sample code for you with Button Example.
Here is the App.js file
import "./styles.css";
import Button from "./Button";
export default function App() {
return (
<div className="App">
<h1>Hello CodeSandbox</h1>
<h2>Start editing to see some magic happen!</h2>
<Button btnText="I'm a Button" />
</div>
);
}
Here is the Button Component.
function Button({ btnText }) {
return (
<div>
<button>{btnText}</button>
</div>
);
}
export default Button;
here is the codesanbox example
Here is how it looks.
Why inline styling doesnt work in react on components?I dont understand why this is not working.I know is possible to make it different ways.(with css files for example).Im just corius.The intellisense does not help by inline styling either.Its strange..
import "./App.css";
import Button from "./components/Button";
function App() {
return (
<div className="App" >
<Button style={{fontSize:"50px"}} />
</div>
);
}
export default App;
//this is from Button components
import React from "react";
const Button = () => {
return (
<div>
<button>
Change
</button>
</div>
);
};
export default Button;
You need to pass the style property to the Button component:
const Button = ({style}) => {
return (
<div>
<button style={style}>
Change
</button>
</div>
);
};
This is my first time trying to use Meteor with ReactJs and React Semantic UI, and having issues on rendering the Semantic UI modal. What I am trying to achieve is to click on the button and open up the modal overlaying on the whole browser, in reference to the React Semantic Modal Manual But what I have right now is that the modal is rendered partially on the screen, as seen from the attached screenshots. Can anyone please help? Thanks in advance.
Main.js
import {Meteor} from 'meteor/meteor';
import React from 'react';
import ReactDOM from 'react-dom';
import {routes} from "../imports/routes/routes";
Meteor.startup(() => {
ReactDOM.render(routes, document.getElementById('app'));
});
Site.js:
import React from 'react';
import { Header, Button, Modal } from 'semantic-ui-react';
import PrivateHeader from './PrivateHeader';
import Sidebar from './Sidebar';
import ModalExample from './Modal';
export class Site extends React.Component {
render() {
return (
<div>
<PrivateHeader/>
<Sidebar/>
<div className="page">
<div className="ui padded one column grid">
<div className="column">
<ModalExample/>
</div>
</div>
</div>
</div>
);
}
}
export default Site;
ModalExample.js
import React from 'react'
import { Button, Header, Icon, Modal } from 'semantic-ui-react'
const ModalBasicExample = () => (
<Modal trigger={<Button>Basic Modal</Button>} basic size='fullscreen'>
<Header icon='archive' content='Archive Old Messages' />
<Modal.Content>
<p>Your inbox is getting full, would you like us to enable automatic archiving of old messages?</p>
</Modal.Content>
<Modal.Actions>
<Button basic color='red' inverted>
<Icon name='remove' /> No
</Button>
<Button color='green' inverted>
<Icon name='checkmark' /> Yes
</Button>
</Modal.Actions>
</Modal>
)
export default ModalBasicExample
Sidebar.js
export const Sidebar = (props) => {
return (
<div className="ui inverted vertical left fixed menu" >
<a className="item" href="/">
<img src='/images/logo.png' className="ui mini right spaced image"/>
Semantics UI Test
</a>
<div className="item">
<div className="header">Hosting</div>
<div className="menu">
<a className="item">Shared</a>
<a className="item">Dedicated</a>
</div>
</div>
<div className="item">
<div className="header">Support</div>
<div className="menu">
<a className="item">E-mail Support</a>
<a className="item">FAQs</a>
</div>
</div>
</div>
)
};
export default Sidebar;
Thanks to Saad's comment mentioning the className that I found out that it was due to Semantic UI will add a ui page modals dimmer transition visible active className when the modal is opened. This causes a conflict to my existing page className which is used in other pages, but because of Meteor and React, the various scss are compressed together.
I suggest to run this.show('fullscreen') with an onClick event on trigger button like the following :
<Button onClick={this.show('fullscreen')}>Show Modal</Button>
ModalExample.js
import React, { Component } from 'react'
import { Button, Modal } from 'semantic-ui-react'
class ModalExample extends Component {
state = { open: false }
show = size => () => this.setState({ size, open: true })
close = () => this.setState({ open: false })
render() {
const { open, size } = this.state
return (
<div>
<Button onClick={this.show('fullscreen')}>Show Modal</Button> // Triggering button
<Modal size={size} open={open} onClose={this.close}>
<Modal.Header>
Delete Your Account
</Modal.Header>
<Modal.Content>
<p>Are you sure you want to delete your account</p>
</Modal.Content>
<Modal.Actions>
<Button negative>
No
</Button>
<Button positive icon='checkmark' labelPosition='right' content='Yes' />
</Modal.Actions>
</Modal>
</div>
)
}
}
export default ModalExample
Source