Skip to content

Commit

Permalink
Exposed the Stackable context and created a new Provider for manipul…
Browse files Browse the repository at this point in the history
…ating the `z-index` for all descendants
  • Loading branch information
Yair Even Or authored and yairEO committed Nov 29, 2022
1 parent 2d501fd commit 12ce340
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/components/Stackable/Stackable.zIndex.jsx
Original file line number Diff line number Diff line change
@@ -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}) => (
<StackableContext.Provider value={{zIndex: zIndex || DEFAULT_Z_INDEX}}>
{children}
</StackableContext.Provider>
);

StackableZIndexProvider.propTypes = {
children: propTypes.Node,
zIndex: propTypes.number,
};

export default StackableZIndexProvider;
4 changes: 4 additions & 0 deletions src/components/Stackable/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

0 comments on commit 12ce340

Please sign in to comment.