question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItĀ collects links to all the places you might be looking at while hunting down a tough bug.

And, if youā€™re still stuck at the end, weā€™re happy to hop on a call to see how we can help out.

how to implement sidebar in <div>

See original GitHub issue

Version

2.13.1

Environment

Windows 10 x64, Chrom 61, react 15.4, react-router 4

Reproduction link

https://codepen.io/anon/pen/XeWPog?editors=001

Steps to reproduce

Create CustomSider

const CustomSider = ({sensors, dispatch}) => {
  // console.log({sensors.sensors});
  return (
    <Sider style={{background: '#fff', borderRight: 'solid', borderColor:'#ddd', borderWidth:'5px'}}>
      <Menu mode="inline" theme="light">
          <Menu.Item key="dev1">Device 1</Menu.Item>
          <Menu.Item key="dev2">Device 2</Menu.Item>
          <Menu.Item key="dev3">Device 3</Menu.Item>
      </Menu>
    </Sider>
  );
}

Then add CustomSider.__ANT_LAYOUT_SIDER = true.

For the DOMRender, add

ReactDOM.render(
  <Layout>
    <div><CustomSider></CustomSider></div>
    <Content>Content</Content>
  </Layout>
, mountNode);

Thatā€™s all.

What is expected?

Content to the right of Sider

What is actually happening?

Content under Sider


This happened when I want to put CustomSider in my <Route/> to hide the CustomSider in some routes.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
yasinuslucommented, Oct 4, 2017

Of course this is not that important but i would be happier if it just worked. I just lost some time trying to figure out why it doesnā€™t work. šŸ˜ƒ

Itā€™s not ideal but i was thinking of doing something like this

1reaction
yasinuslucommented, Oct 3, 2017

Hi @nikogu,

I just had the same issue and digged into ant designā€™s source code. I found following code in here:

React.Children.forEach(children, (element: any) => {
  if (element && element.type && element.type.__ANT_LAYOUT_SIDER) {
    hasSider = true;
  }
});
const divCls = classNames(className, prefixCls, {
  [`${prefixCls}-has-sider`]: hasSider,
});

It could be easily implemented using contexts, is this by design ? If so could you explain your reasoning behind this behaviour ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

CSS Sidebars: A Beginner's Guide - HubSpot Blog
The simplest way to implement a sidebar is with a static sidebar element (colored blue below) that spans the height of the page...
Read more >
How To Create a Responsive Sidebar - W3Schools
Learn how to create a responsive side navigation menu with CSS. ... This example use media queries to transform the sidebar to a...
Read more >
Sidebar Menu Using HTML and CSS - DEV Community ā€ ā€
Step 1: Create a basic html structure to create sidebars Ā· Step 2: Design the background using css code Ā· Step 3: Add...
Read more >
How make sidebar slide inside of a div and not the body?
Wrap the whole ul-menu called "side-menu" in a div. Second step: ... Now style the wrapper div of the ul to your own...
Read more >
Responsive Sidebar Component in HTML, CSS and JavaScript
Use the data-static-class="{class}" attribute on the .sidebar element if you want to add a list of classes to the sidebar when it's in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found