Skip to content

Commit

Permalink
Related #4352, #4602 - For Misc
Browse files Browse the repository at this point in the history
  • Loading branch information
ulasturann committed Aug 22, 2023
1 parent a5f2cda commit 68f6522
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 41 deletions.
12 changes: 10 additions & 2 deletions components/lib/avatar/Avatar.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import { PrimeReactContext } from '../api/Api';
import { useHandleStyle } from '../componentbase/ComponentBase';
import { IconUtils, ObjectUtils, classNames, mergeProps } from '../utils/Utils';
import { DomHandler, IconUtils, ObjectUtils, classNames, mergeProps } from '../utils/Utils';
import { AvatarBase } from './AvatarBase';

export const Avatar = React.forwardRef((inProps, ref) => {
Expand All @@ -10,11 +10,13 @@ export const Avatar = React.forwardRef((inProps, ref) => {

const elementRef = React.useRef(null);
const [imageFailed, setImageFailed] = React.useState(false);
const [isNestedInAvatarGroup, setisNestedInAvatarGroup] = React.useState(false);

const { ptm, cx, isUnstyled } = AvatarBase.setMetaData({
props,
state: {
imageFailed: imageFailed
imageFailed: imageFailed,
isNestedInAvatarGroup
}
});

Expand Down Expand Up @@ -69,6 +71,12 @@ export const Avatar = React.forwardRef((inProps, ref) => {
props.onImageError && props.onImageError(event);
};

React.useEffect(() => {
const isInAG = DomHandler.isAttributeEquals(elementRef.current.parentElement, 'data-pc-name', 'avatargroup');

setisNestedInAvatarGroup(isInAG);
},[])

React.useImperativeHandle(ref, () => ({
props,
getElement: () => elementRef.current
Expand Down
17 changes: 17 additions & 0 deletions components/lib/avatar/avatar.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,23 @@ export declare type AvatarPassThroughType<T> = PassThroughType<T, AvatarPassThro
*/
export interface AvatarPassThroughMethodOptions {
props: AvatarProps;
state: AvatarState;
}

/**
* Defines current inline state in Avatar component.
*/
export interface AvatarState {
/**
* Current imageFailed state as a boolean.
* @defaultValue false
*/
imageFailed: boolean;
/**
* Current state that indicates whether the Avatar component is nested within an AvatarGroup component.
* @defaultValue false
*/
isNestedInAvatarGroup: boolean;
}

/**
Expand Down
11 changes: 9 additions & 2 deletions components/lib/blockui/BlockUI.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,16 @@ export const BlockUI = React.forwardRef((inProps, ref) => {
if (visibleState) {
const appendTo = props.fullScreen ? document.body : 'self';
const maskProps =
({
mergeProps({
className: cx('mask'),
style: props.style
style: {
...props.style,
position: props.fullScreen ? 'fixed' : 'absolute',
top: '0',
left: '0',
width: '100%',
height: '100%'
}
},
ptm('mask'));
const content = props.template ? ObjectUtils.getJSXElement(props.template, props) : null;
Expand Down
5 changes: 0 additions & 5 deletions components/lib/blockui/BlockUIBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ const styles = `
}
.p-blockui {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
opacity: 1;
display: flex;
align-items: center;
Expand Down
28 changes: 14 additions & 14 deletions components/lib/editor/Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,48 +162,48 @@ export const Editor = React.memo(
} else {
const getMergeProps = (params, key) => mergeProps(params && { ...params }, ptm(key));

const formatsProps = mergeProps({ className: cx('formats') }, ptm('formats'));
const formatsProps = mergeProps({ className: 'ql-formats' }, ptm('formats'));

return (
<div {...toolbarProps}>
<span {...formatsProps}>
<select {...getMergeProps({ className: cx('header'), defaultValue: '0' }, 'header')}>
<select {...getMergeProps({ className: 'ql-header', defaultValue: '0' }, 'header')}>
<option {...getMergeProps({ value: '1' }, 'option')}>Heading</option>
<option {...getMergeProps({ value: '2' }, 'option')}>Subheading</option>
<option {...getMergeProps({ value: '0' }, 'option')}>Normal</option>
</select>
<select {...getMergeProps({ className: cx('font') }, 'font')}>
<select {...getMergeProps({ className: 'ql-font' }, 'font')}>
<option {...getMergeProps(undefined, 'option')}></option>
<option {...getMergeProps({ value: 'serif' }, 'option')}></option>
<option {...getMergeProps({ value: 'monospace' }, 'option')}></option>
</select>
</span>
<span {...formatsProps}>
<button {...getMergeProps({ type: 'button', className: cx('bold'), 'aria-label': 'Bold' }, 'bold')}></button>
<button {...getMergeProps({ type: 'button', className: cx('italic'), 'aria-label': 'Italic' }, 'italic')}></button>
<button {...getMergeProps({ type: 'button', className: cx('underline'), 'aria-label': 'Underline' }, 'underline')}></button>
<button {...getMergeProps({ type: 'button', className: 'ql-bold', 'aria-label': 'Bold' }, 'bold')}></button>
<button {...getMergeProps({ type: 'button', className: 'ql-italic', 'aria-label': 'Italic' }, 'italic')}></button>
<button {...getMergeProps({ type: 'button', className: 'ql-underline', 'aria-label': 'Underline' }, 'underline')}></button>
</span>
<span {...formatsProps}>
<select {...getMergeProps({ className: cx('color') }, 'color')}></select>
<select {...getMergeProps({ className: cx('background') }, 'background')}></select>
<select {...getMergeProps({ className: 'ql-color' }, 'color')}></select>
<select {...getMergeProps({ className: 'ql-background' }, 'background')}></select>
</span>
<span {...formatsProps}>
<button {...getMergeProps({ type: 'button', className: cx('list'), value: 'ordered', 'aria-label': 'Ordered List' }, 'list')}></button>
<button {...getMergeProps({ type: 'button', className: 'ql-list', value: 'ordered', 'aria-label': 'Ordered List' }, 'list')}></button>
<button {...getMergeProps({ type: 'button', className: cx('list'), value: 'bullet', 'aria-label': 'Unordered List' }, 'list')}></button>
<select {...getMergeProps({ className: cx('select') }, 'select')}>
<select {...getMergeProps({ className: 'ql-align' }, 'select')}>
<option {...getMergeProps({ defaultValue: true }, 'option')}></option>
<option {...getMergeProps({ value: 'center' }, 'option')}></option>
<option {...getMergeProps({ value: 'right' }, 'option')}></option>
<option {...getMergeProps({ value: 'justify' }, 'option')}></option>
</select>
</span>
<span {...formatsProps}>
<button {...getMergeProps({ type: 'button', className: cx('link'), 'aria-label': 'Insert Link' }, 'link')}></button>
<button {...getMergeProps({ type: 'button', className: cx('image'), 'aria-label': 'Insert Image' }, 'image')}></button>
<button {...getMergeProps({ type: 'button', className: cx('codeBlock'), 'aria-label': 'Insert Code Block' }, 'codeBlock')}></button>
<button {...getMergeProps({ type: 'button', className: 'ql-link', 'aria-label': 'Insert Link' }, 'link')}></button>
<button {...getMergeProps({ type: 'button', className: 'ql-image', 'aria-label': 'Insert Image' }, 'image')}></button>
<button {...getMergeProps({ type: 'button', className: 'ql-code-block', 'aria-label': 'Insert Code Block' }, 'codeBlock')}></button>
</span>
<span {...formatsProps}>
<button {...getMergeProps({ type: 'button', className: cx('clean'), 'aria-label': 'Remove Styles' }, 'clean')}></button>
<button {...getMergeProps({ type: 'button', className: 'ql-clean', 'aria-label': 'Remove Styles' }, 'clean')}></button>
</span>
</div>
);
Expand Down
14 changes: 0 additions & 14 deletions components/lib/editor/EditorBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,6 @@ import { classNames } from '../utils/Utils';
const classes = {
root: ({ props }) => classNames('p-component p-editor-container', props.className),
toolbar: 'p-editor-toolbar',
formats: 'ql-formats',
header: 'ql-header',
font: 'ql-font',
bold: 'ql-bold',
italic: 'ql-italic',
underline: 'ql-underline',
color: 'ql-color',
background: 'ql-background',
list: 'ql-list',
select: 'ql-align',
link: 'ql-link',
image: 'ql-image',
codeBlock: 'ql-code-block',
clean: 'ql-clean',
content: 'p-editor-content'
};

Expand Down
8 changes: 4 additions & 4 deletions components/lib/passthrough/tailwind/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1512,7 +1512,7 @@ const Tailwind = {
})
},
avatar: {
root: ({ props, parent }) => ({
root: ({ props, state }) => ({
className: classNames(
'flex items-center justify-center',
'bg-gray-300 dark:bg-gray-800',
Expand All @@ -1524,10 +1524,10 @@ const Tailwind = {
'text-base h-8 w-8': props.size == null || props.size == 'normal',
'w-12 h-12 text-xl': props.size == 'large',
'w-16 h-16 text-2xl': props.size == 'xlarge'
},
{
'-ml-4 border-2 border-white dark:border-gray-900': state.isNestedInAvatarGroup
}
// {
// '-ml-4 border-2 border-white dark:border-gray-900': parent.instance !== undefined
// }
)
}),
image: 'h-full w-full'
Expand Down

0 comments on commit 68f6522

Please sign in to comment.