-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(Actions): Add Actions component #139
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import mapKeys from 'lodash/mapKeys'; | ||
import { Tokens } from '../themes/theme'; | ||
import createDesktopRules from './utils/makeDesktopRules'; | ||
|
||
const defaultFlexDirectionPrefix = '.flexDirection_'; | ||
const desktopFlexDirectionPrefix = '.flexDirectionDesktop_'; | ||
|
||
const flexDirectionRules = { | ||
row: { flexDirection: 'row' }, | ||
column: { flexDirection: 'column' }, | ||
}; | ||
|
||
const defaultFlexDirectionRules = mapKeys( | ||
flexDirectionRules, | ||
(value, key) => `${defaultFlexDirectionPrefix}${key}`, | ||
); | ||
const desktopFlexDirectionRules = mapKeys( | ||
flexDirectionRules, | ||
(value, key) => `${desktopFlexDirectionPrefix}${key}`, | ||
); | ||
|
||
export default (tokens: Tokens) => ({ | ||
...defaultFlexDirectionRules, | ||
...createDesktopRules({ tokens, css: desktopFlexDirectionRules }), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import React from 'react'; | ||
import Actions from './Actions'; | ||
import Button from '../Button/Button'; | ||
import TextLink from '../TextLink/TextLink'; | ||
import { ComponentDocs } from '../../../docs/src/types'; | ||
|
||
const docs: ComponentDocs = { | ||
examples: [ | ||
{ | ||
label: 'Actions with Strong Button and TextLink', | ||
render: () => ( | ||
<Actions> | ||
<Button weight="strong">Strong</Button> | ||
<TextLink href="#">TextLink</TextLink> | ||
</Actions> | ||
), | ||
}, | ||
{ | ||
label: 'Actions with Regular Button and Weak Button', | ||
render: () => ( | ||
<Actions> | ||
<Button weight="regular">Regular</Button> | ||
<Button weight="weak">Weak</Button> | ||
</Actions> | ||
), | ||
}, | ||
{ | ||
label: 'Actions with Weak Buttons and Regular Button', | ||
render: () => ( | ||
<Actions> | ||
<Button weight="weak">Weak</Button> | ||
<Button weight="weak">Weak</Button> | ||
<Button weight="regular">Regular</Button> | ||
</Actions> | ||
), | ||
}, | ||
], | ||
}; | ||
|
||
export default docs; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import React, { Component, Children, ReactNode } from 'react'; | ||
import { ActionsProvider } from './ActionsContext'; | ||
import Box from '../Box/Box'; | ||
|
||
export interface ActionsProps { | ||
children: ReactNode; | ||
} | ||
|
||
export default class Actions extends Component<ActionsProps> { | ||
static displayName = 'Actions'; | ||
|
||
render() { | ||
const { children } = this.props; | ||
|
||
return ( | ||
<ActionsProvider value={true}> | ||
<Box display="flex" flexDirection={['column', 'row']}> | ||
{Children.map(children, (child, index) => | ||
index === 0 ? ( | ||
<div>{child}</div> | ||
) : ( | ||
<Box | ||
paddingLeft={['none', 'xsmall']} | ||
paddingTop={['xsmall', 'none']} | ||
> | ||
{child} | ||
</Box> | ||
), | ||
)} | ||
</Box> | ||
</ActionsProvider> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { createContext } from 'react'; | ||
|
||
const { Provider, Consumer } = createContext(false); | ||
|
||
export const ActionsProvider = Provider; | ||
export const ActionsConsumer = Consumer; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
// This file is automatically generated. | ||
// Please do not change this file! | ||
export const focusOverlay: string; | ||
export const overlayContainer: string; | ||
export const root: string; | ||
export const root_isButton: string; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💪