Skip to content
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

Refactor/ds 926 prefixes of utilities and helpers #1051

Merged
merged 2 commits into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions packages/web-react/src/components/Breadcrumbs/Breadcrumbs.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import React, { ElementType } from 'react';
import classNames from 'classnames';
import { useBreadcrumbsStyleProps } from './useBreadcrumbsStyleProps';
import { SpiritBreadcrumbsProps } from '../../types';
import React, { ElementType } from 'react';
import { useClassNamePrefix } from '../../hooks';
import { useStyleProps } from '../../hooks/styleProps';
import { SpiritBreadcrumbsProps } from '../../types';
import { Icon } from '../Icon';
import { Link } from '../Link';
import { useBreadcrumbsStyleProps } from './useBreadcrumbsStyleProps';

const defaultProps = {
items: [],
Expand All @@ -15,6 +16,10 @@ export const Breadcrumbs = <T extends ElementType = 'nav'>(props: SpiritBreadcru
const { classProps, props: modifiedProps } = useBreadcrumbsStyleProps({ ...restProps });
const { styleProps, props: otherProps } = useStyleProps(modifiedProps);

const displayTabletNoneClassName = useClassNamePrefix('d-tablet-none');
const displayNoneClassName = useClassNamePrefix('d-none');
const displayTabletFlexClassName = useClassNamePrefix('d-tablet-flex');

const isLast = (index: number, itemsCount: number) => {
return index === itemsCount - 1;
};
Expand All @@ -31,14 +36,14 @@ export const Breadcrumbs = <T extends ElementType = 'nav'>(props: SpiritBreadcru
items?.map((item, index) => (
<React.Fragment key={`BreadcrumbsItem_${item.title}`}>
{index === items.length - 2 && goBackTitle && (
<li className="d-tablet-none">
<li className={displayTabletNoneClassName}>
<Icon name="chevron-left" />
<Link href={item.url} color="primary" isUnderlined>
{goBackTitle}
</Link>
</li>
)}
<li className="d-none d-tablet-flex">
<li className={classNames(displayNoneClassName, displayTabletFlexClassName)}>
{index !== 0 && <Icon name="chevron-right" />}
<Link
href={item.url}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useRef, RefObject, MouseEvent, useState } from 'react';
import classNames from 'classnames';
import { SpiritFileUploaderAttachmentProps } from '../../types';
import { useDeprecationMessage, useStyleProps } from '../../hooks';
import { useClassNamePrefix, useDeprecationMessage, useStyleProps } from '../../hooks';
import { useFileUploaderStyleProps } from './useFileUploaderStyleProps';
import { useFileUploaderAttachment } from './useFileUploaderAttachment';
import AttachmentImagePreview from './AttachmentImagePreview';
Expand Down Expand Up @@ -87,7 +87,7 @@ const FileUploaderAttachment = (props: SpiritFileUploaderAttachmentProps) => {
<Icon name={iconName} aria-hidden="true" />
)}
<span className={classProps.attachment.name}>
<span className="text-truncate">{label}</span>
<span className={useClassNamePrefix('text-truncate')}>{label}</span>
</span>
{onEdit && (
<span className={classProps.attachment.slot}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

{# Class names #}
{%- set _rootClassName = _spiritClassPrefix ~ 'Breadcrumbs' -%}
{%- set _displayNoneClassName = _spiritClassPrefix ~ 'd-none' -%}
{%- set _displayTabletNoneClassName = _spiritClassPrefix ~ 'd-tablet-none' -%}
{%- set _displayTabletFlexClassName = _spiritClassPrefix ~ 'd-tablet-flex' -%}

{# Miscellaneous #}
{%- set _styleProps = useStyleProps(props) -%}
Expand All @@ -22,12 +25,12 @@
<ol>
{% for item in _items %}
{% if loop.index is same as(_items|length - 1) and _goBackTitle is not same as('') %}
<li class="d-tablet-none">
<li class="{{ _displayTabletNoneClassName }}">
<Icon name="chevron-left" />
<Link href="{{ item.url }}" color="primary" isUnderlined>{{ _goBackTitle }}</Link>
</li>
{% endif %}
<li class="d-none d-tablet-flex">
<li {{ classProp([_displayNoneClassName, _displayTabletFlexClassName]) }}>
{% if loop.index0 is not same as(0) %}
<Icon name="chevron-right" />
{% endif %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
{%- set _rootClassName = _spiritClassPrefix ~ 'FileUploaderAttachment' -%}
{%- set _imageClassName = _spiritClassPrefix ~ 'FileUploaderAttachment__image' -%}
{%- set _nameClassName = _spiritClassPrefix ~ 'FileUploaderAttachment__name' -%}
{%- set _removeClassName = _spiritClassPrefix ~ 'FileUploaderAttachment__action' -%}
{%- set _actionClassName = _spiritClassPrefix ~ 'FileUploaderAttachment__action' -%}
{%- set _slotClassName = _spiritClassPrefix ~ 'FileUploaderAttachment__slot' -%}
{%- set _textTruncateClassName = _spiritClassPrefix ~ 'text-truncate' -%}

{# Attributes #}
{%- set _dataImagePreviewAttr = _generateImagePreview ? 'data-spirit-imagePreview="true"' : null -%}
Expand All @@ -38,21 +40,21 @@
<Icon name="{{ _iconName }}" isReusable={ false } />
{% endif %}
<span class="{{ _nameClassName }}">
<span class="text-truncate" data-spirit-populate-field="name">
<span class="{{ _textTruncateClassName }}" data-spirit-populate-field="name">
{{- _fileName -}}
</span>
</span>
literat marked this conversation as resolved.
Show resolved Hide resolved
{% if _onEdit %}
<span class="FileUploaderAttachment__slot">
<button type="button" class="FileUploaderAttachment__action" onclick="{{ _onEdit }}">
<span class="{{ _slotClassName }}">
<button type="button" class="{{ _actionClassName }}" onclick="{{ _onEdit }}">
literat marked this conversation as resolved.
Show resolved Hide resolved
<VisuallyHidden>{{ _editText }}</VisuallyHidden>
<Icon name="edit" isReusable={ false } />
</button>
</span>
{% endif %}
<button
type="button"
class="{{ _removeClassName }}"
class="{{ _actionClassName }}"
data-spirit-populate-field="button"
>
<VisuallyHidden>{{ _removeText }}</VisuallyHidden>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
{%- set _labelHiddenClassName = _isLabelHidden ? _spiritClassPrefix ~ 'FileUploaderInput__label--hidden' : null -%}
{%- set _labelRequiredClassName = _isRequired ? _spiritClassPrefix ~ 'FileUploaderInput__label--required' : null -%}
{%- set _linkClassName = _spiritClassPrefix ~ 'FileUploaderInput__link' -%}
{%- set _linkPrimaryClassName = _spiritClassPrefix ~ 'link-primary' -%}
{%- set _linkUnderlinedClassName = _spiritClassPrefix ~ 'link-underlined' -%}
{%- set _validationTextClassName = _spiritClassPrefix ~ 'FileUploaderInput__validationText' -%}

{# Attributes #}
Expand Down Expand Up @@ -78,7 +80,7 @@
<div class="{{ _dropzoneClassName }}" data-spirit-element="dropZone">
<Icon name="{{ _iconName }}" isReusable={false} />
<label for="{{ _id }}" class="{{ _dropzoneLabelClassName }}">
<span class="{{ _linkClassName }} link-primary link-underlined">
<span {{ classProp([_linkClassName, _linkPrimaryClassName, _linkUnderlinedClassName]) }}>
{{- _pickAFileText -}}
</span>
<span class="{{ _dragAndDropLabelClassName }}">
Expand Down