From 12ce34065e6f963c05ed94a3a177f545140be5f4 Mon Sep 17 00:00:00 2001 From: Yair Even Or Date: Thu, 10 Nov 2022 11:31:16 +0200 Subject: [PATCH] Exposed the Stackable context and created a new Provider for manipulating the `z-index` for all descendants --- src/components/Stackable/Stackable.zIndex.jsx | 32 +++++++++++++++++++ src/components/Stackable/index.js | 4 +++ 2 files changed, 36 insertions(+) create mode 100644 src/components/Stackable/Stackable.zIndex.jsx diff --git a/src/components/Stackable/Stackable.zIndex.jsx b/src/components/Stackable/Stackable.zIndex.jsx new file mode 100644 index 0000000..ee0752a --- /dev/null +++ b/src/components/Stackable/Stackable.zIndex.jsx @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2020, Amdocs Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import React from 'react'; +import propTypes from 'prop-types'; +import {DEFAULT_Z_INDEX} from './Stackable.constants'; +import StackableContext from './Stackable.context'; + +const StackableZIndexProvider = ({children, zIndex}) => ( + + {children} + +); + +StackableZIndexProvider.propTypes = { + children: propTypes.Node, + zIndex: propTypes.number, +}; + +export default StackableZIndexProvider; \ No newline at end of file diff --git a/src/components/Stackable/index.js b/src/components/Stackable/index.js index e877f00..4f88033 100644 --- a/src/components/Stackable/index.js +++ b/src/components/Stackable/index.js @@ -16,7 +16,11 @@ import Stackable from './Stackable'; import {getAncestors} from './Stackable.utils'; +import StackableContext from './Stackable.context'; +import StackableZIndexProvider from './Stackable.zIndex'; Stackable.getAncestors = getAncestors; +Stackable.context = StackableContext; +Stackable.zIndex = StackableZIndexProvider; export default Stackable;