-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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(gradient): linear gradient mixin #15081
Changes from 6 commits
1067339
722e5ff
ac665a9
9440082
5609163
b23518a
482bb7d
16714df
751385e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* Copyright IBM Corp. 2023 | ||
* | ||
* This source code is licensed under the Apache-2.0 license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { Tile } from '../Tile'; | ||
import { TextInput } from '../TextInput'; | ||
import './linear-gradient-story.scss'; | ||
|
||
export default { | ||
title: 'Experimental/unstable__LinearGradient', | ||
component: Tile, | ||
}; | ||
|
||
export const Demo = () => ( | ||
<> | ||
<div className="gradient-container"> | ||
<Tile className="top">Top</Tile> | ||
<Tile className="right">Right</Tile> | ||
<Tile className="bottom">Bottom</Tile> | ||
<Tile className="left">Left</Tile> | ||
</div> | ||
<br /> | ||
<br /> | ||
<div className="gradient-container"> | ||
<TextInput labelText="Full width" className="full-width" /> | ||
<TextInput labelText="Half width" className="half-width" /> | ||
<TextInput labelText="Third width" className="third-width" /> | ||
<TextInput labelText="Quarter width" className="quarter-width" /> | ||
</div> | ||
</> | ||
); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
@use '../../../../styles/scss/utilities/ai-gradient' as *; | ||
|
||
.gradient-container { | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: space-between; | ||
} | ||
|
||
.gradient-container > * { | ||
margin: 0 0.5rem; | ||
} | ||
|
||
.gradient-container > .cds--tile { | ||
min-height: 250px; | ||
min-width: 150px; | ||
} | ||
|
||
.top { | ||
@include ai-gradient('top'); | ||
} | ||
|
||
.right { | ||
@include ai-gradient('right'); | ||
} | ||
|
||
.bottom { | ||
@include ai-gradient('bottom'); | ||
} | ||
|
||
.left { | ||
@include ai-gradient('left'); | ||
} | ||
|
||
.full-width .cds--text-input { | ||
@include ai-gradient('right', 100%); | ||
} | ||
|
||
.half-width .cds--text-input { | ||
@include ai-gradient('right', 50%); | ||
} | ||
|
||
.third-width .cds--text-input { | ||
@include ai-gradient('right', 33%); | ||
} | ||
|
||
.quarter-width .cds--text-input { | ||
@include ai-gradient('right', 25%); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// | ||
// Copyright IBM Corp. 2021 | ||
// | ||
// This source code is licensed under the Apache-2.0 license found in the | ||
// LICENSE file in the root directory of this source tree. | ||
// | ||
|
||
@use '../theme'; | ||
|
||
/// Adds AI gradient styles to a component | ||
/// @access public | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should |
||
/// @param {String} $direction - Direction of gradient from: `left`, `right`, `top`, and `bottom` | ||
/// @param {Number} $width - Percentage width of gradient with regards to parent component | ||
/// @example @include focus-outline('outline'); | ||
/// @group utilities | ||
|
||
@mixin ai-gradient($direction: 'right', $width: 50%) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm also questioning our use of This could be more future proof. What happens when everything is "AI". We don't want our code base littered with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah @tay1orjones has mentioned the same thing about the "ai" term. We haven't finalized the token name yet just launching something so TJ isn't blocked for the next implementation steps. I think we were going to try and avoid "gradient" as well since that's not scalable (could evolve to something other than a linear gradient). I was thinking it could just be a flavor of "aura" (like |
||
$deg: 0; | ||
@if $direction == 'bottom' { | ||
$deg: 0deg; | ||
} @else if $direction == 'left' { | ||
$deg: 90deg; | ||
} @else if $direction == 'top' { | ||
$deg: 180deg; | ||
} @else if $direction == 'right' { | ||
$deg: 270deg; | ||
} | ||
|
||
background-image: linear-gradient( | ||
$deg, | ||
theme.$ai-gradient-start-01 0%, | ||
theme.$ai-gradient-end $width, | ||
transparent 100% | ||
), | ||
linear-gradient( | ||
$deg, | ||
theme.$ai-gradient-start-02 0%, | ||
theme.$ai-gradient-end $width, | ||
transparent 100% | ||
); | ||
} |
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.
I'm not sure about having this in the storybook long term. Feels more like something we should find a way to document in the Themes elements example. Not a blocker for this PR, but something to consider for the future.
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.
Yeah I can remove this before we merge 👍🏻