forked from mui/material-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[pigment-css][react] RTL Support (mui#41570)
- Loading branch information
1 parent
db62e97
commit 52b8ca6
Showing
15 changed files
with
349 additions
and
37 deletions.
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
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 @@ | ||
'use client'; | ||
/** | ||
* This package has it's own version of RtlProvider to avoid including | ||
* @mui/system in the bundle if someone is not using it. | ||
*/ | ||
import * as React from 'react'; | ||
|
||
type RtlContextType = boolean | undefined; | ||
|
||
type RtlProviderProps = { | ||
value?: RtlContextType; | ||
}; | ||
|
||
const RtlContext = React.createContext<RtlContextType>(false); | ||
|
||
function RtlProvider({ value, ...props }: RtlProviderProps) { | ||
return <RtlContext.Provider value={value ?? true} {...props} />; | ||
} | ||
|
||
export const useRtl = () => { | ||
const value = React.useContext(RtlContext); | ||
return value ?? false; | ||
}; | ||
|
||
export default RtlProvider; |
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
33 changes: 33 additions & 0 deletions
33
packages/pigment-css-react/tests/styled/fixtures/styled-rtl.input.js
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,33 @@ | ||
import { styled, keyframes } from '@pigment-css/react'; | ||
|
||
const rotateKeyframe = keyframes({ | ||
from: { | ||
transform: 'translateX(0%)', | ||
}, | ||
to: { | ||
transform: 'translateX(100%)', | ||
}, | ||
}); | ||
|
||
const Component = styled.div(({ theme }) => ({ | ||
animation: `${rotateKeyframe} 2s ease-out 0s infinite`, | ||
marginLeft: 10, | ||
})); | ||
|
||
export const SliderRail = styled('span', { | ||
name: 'MuiSlider', | ||
slot: 'Rail', | ||
})` | ||
display: block; | ||
position: absolute; | ||
left: 0; | ||
top: 0; | ||
border-top-left-radius: 3px; | ||
`; | ||
|
||
const SliderRail2 = styled.span` | ||
${SliderRail} { | ||
padding-inline-start: none; | ||
margin: 0px 10px 10px 30px; | ||
} | ||
`; |
44 changes: 44 additions & 0 deletions
44
packages/pigment-css-react/tests/styled/fixtures/styled-rtl.output.css
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,44 @@ | ||
@keyframes r14vlhb { | ||
from { | ||
transform: translateX(0%); | ||
} | ||
to { | ||
transform: translateX(100%); | ||
} | ||
} | ||
.c194j3ko { | ||
animation: r14vlhb 2s ease-out 0s infinite; | ||
margin-left: 10px; | ||
} | ||
:dir(rtl) .c194j3ko { | ||
animation: r14vlhb 2s ease-out 0s infinite; | ||
margin-right: 10px; | ||
} | ||
.sgip8u5 { | ||
display: block; | ||
position: absolute; | ||
left: 0; | ||
top: 0; | ||
border-top-left-radius: 3px; | ||
} | ||
:dir(rtl) .sgip8u5 { | ||
display: block; | ||
position: absolute; | ||
right: 0; | ||
top: 0; | ||
border-top-right-radius: 3px; | ||
} | ||
.sgip8u5-1 { | ||
font-size: 1.5rem; | ||
} | ||
:dir(rtl) .sgip8u5-1 { | ||
font-size: 1.5rem; | ||
} | ||
.smip3v5 .sgip8u5 { | ||
padding-inline-start: none; | ||
margin: 0px 10px 10px 30px; | ||
} | ||
:dir(rtl) .smip3v5 .sgip8u5 { | ||
padding-inline-start: none; | ||
margin: 0px 30px 10px 10px; | ||
} |
16 changes: 16 additions & 0 deletions
16
packages/pigment-css-react/tests/styled/fixtures/styled-rtl.output.js
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,16 @@ | ||
import { styled as _styled3 } from '@pigment-css/react'; | ||
import { styled as _styled2 } from '@pigment-css/react'; | ||
import { styled as _styled } from '@pigment-css/react'; | ||
import _theme from '@pigment-css/react/theme'; | ||
const Component = /*#__PURE__*/ _styled('div')({ | ||
classes: ['c194j3ko'], | ||
}); | ||
export const SliderRail = /*#__PURE__*/ _styled2('span', { | ||
name: 'MuiSlider', | ||
slot: 'Rail', | ||
})({ | ||
classes: ['sgip8u5', 'sgip8u5-1'], | ||
}); | ||
const SliderRail2 = /*#__PURE__*/ _styled3('span')({ | ||
classes: ['smip3v5'], | ||
}); |
Oops, something went wrong.