Git Product home page Git Product logo

children's Introduction

Lab #1: Children

Your job in this lab is to build four components: TabGroup, Tab, TabTitle and TabContent. These four components should be used like so:

<TabGroup>
	<Tab>
		<TabTitle>Some title</TabTitle>
		<TabContent>Some content</TabContent>
	</Tab>
	<Tab>
		<TabTitle>Some title</TabTitle>
		<TabContent>Some content</TabContent>
	</Tab>
	<Tab>
		<TabTitle>Some title</TabTitle>
		<TabContent>Some content</TabContent>
	</Tab>
</TabGroup>

The TabTitle of each tab should always be visible, but the content should only be shown when the tab is selected by clicking on the title.

Tips

You should not use any CSS tricks to make this happen, we want to see a pure JavaScript solution. (brownie points for making it look good, though)

The TabGroup needs to manage the tab selection. The trick is to pass two properties down to each Tab:

  • selected (Boolean): Is this the selected tab
  • onClick (Function): When called should select the tab that the call came from

The Tab itself then needs to render its Title and Content, making sure to always show the Title, calling props.onClick when that is pressed and only show the Content when props.selected is true.

Bonus

If you finish this exercise early, you can try enforcing that the TabGroup only has Tab components as children, and that the Tab component only has TabTitle and TabContent (and each only once) as children!

children's People

Contributors

mxstbr avatar

Stargazers

Grégory Houllier avatar Manuel Penaloza avatar Anton Rusinov avatar

Watchers

Nik Graf avatar James Cloos avatar  avatar

Forkers

nirbenita

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.