Skip to content

Commit

Permalink
Switch to Tabs from web-common
Browse files Browse the repository at this point in the history
* Update web-common to 0.3.0
* Tab now uses <button> instead <a>
* Removed box-shadow from a tab when it is focused with keyboard
  • Loading branch information
tnajdek committed Aug 1, 2023
1 parent cc38fe8 commit 9a8a57a
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 169 deletions.
2 changes: 1 addition & 1 deletion modules/web-common
3 changes: 1 addition & 2 deletions src/js/component/item-details/attachments.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import CSSTransition from 'react-transition-group/cjs/CSSTransition';
import { NativeTypes } from 'react-dnd-html5-backend';
import { useDispatch, useSelector } from 'react-redux';
import { useDrag, useDrop } from 'react-dnd';
import { Button, Icon, Spinner } from 'web-common/components';
import { Button, Icon, Spinner, TabPane } from 'web-common/components';
import { useFocusManager } from 'web-common/hooks';
import { noop, isTriggerEvent } from 'web-common/utils';

Expand All @@ -18,7 +18,6 @@ tryGetAttachmentURL, toggleModal, updateItem } from '../../actions';
import { get, getScrollContainerPageCount, getUniqueId, openDelayedURL, stopPropagation, sortByKey } from '../../utils';
import { getFileData } from '../../common/event';
import { pluralize } from '../../common/format';
import { TabPane } from '../ui/tabs';
import { Toolbar, ToolGroup } from '../ui/toolbars';
import { makePath } from '../../common/navigation';
import { useForceUpdate, useFetchingState } from '../../hooks';
Expand Down
2 changes: 1 addition & 1 deletion src/js/component/item-details/info.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { memo } from 'react';
import { useSelector } from 'react-redux';
import PropTypes from 'prop-types';
import cx from 'classnames';
import { TabPane } from 'web-common/components';

import ItemBox from './box';
import Abstract from './abstract';
import { getBaseMappedValue } from '../../common/item';
import { TabPane } from '../ui/tabs';
import { get } from '../../utils';

const Info = ({ isActive, isReadOnly, id }) => {
Expand Down
3 changes: 1 addition & 2 deletions src/js/component/item-details/notes.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import cx from 'classnames';
import { Button, Dropdown, DropdownToggle, DropdownMenu, DropdownItem, Icon } from 'web-common/components';
import { Button, Dropdown, DropdownToggle, DropdownMenu, DropdownItem, Icon, TabPane } from 'web-common/components';
import PropTypes from 'prop-types';
import { memo, forwardRef, useCallback, useEffect, useState, useRef } from 'react';
import { useDispatch, useSelector } from 'react-redux';
Expand All @@ -11,7 +11,6 @@ import RichEditor from 'component/rich-editor';
import { get } from 'utils';
import { noteAsTitle, pluralize } from 'common/format';
import { getScrollContainerPageCount, sortByKey, stopPropagation } from 'utils';
import { TabPane } from 'component/ui/tabs';
import { Toolbar, ToolGroup } from 'component/ui/toolbars';
import { useFetchingState, usePrepForUnmount } from 'hooks';
import { deleteItem, deleteUnusedEmbeddedImages, createItem, updateItem, fetchChildItems,
Expand Down
3 changes: 1 addition & 2 deletions src/js/component/item-details/related.jsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import PropTypes from 'prop-types';
import { memo, useCallback, useEffect, useRef } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { Button, Icon } from 'web-common/components';
import { Button, Icon, TabPane } from 'web-common/components';
import { useFocusManager } from 'web-common/hooks';
import { isTriggerEvent, noop } from 'web-common/utils';

import { fetchRelatedItems, navigate, removeRelatedItem } from '../../actions';
import { getItemTitle } from '../../common/item';
import { get, getScrollContainerPageCount, getUniqueId, mapRelationsToItemKeys, sortItemsByKey, } from '../../utils';
import { TabPane } from '../ui/tabs';


const RelatedItem = memo(props => {
Expand Down
2 changes: 1 addition & 1 deletion src/js/component/item-details/standalone-attachment.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import PropTypes from 'prop-types';
import { useSelector } from 'react-redux';
import { TabPane } from 'web-common/components';

import { TabPane } from '../ui/tabs';
import AttachmentDetails from './attachment-details';

const StandaloneAttachmentTabPane = ({ id, isActive, isReadOnly }) => {
Expand Down
2 changes: 1 addition & 1 deletion src/js/component/item-details/standalone-note.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { useCallback } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import PropTypes from 'prop-types';
import { TabPane } from 'web-common/components';

import RichEditor from 'component/rich-editor';
import { get } from 'utils';
import { deleteUnusedEmbeddedImages, updateItem } from 'actions';
import { TabPane } from 'component/ui/tabs';
import { usePrepForUnmount } from '../../hooks';

const StandaloneNote = ({ id, isActive, isReadOnly }) => {
Expand Down
4 changes: 2 additions & 2 deletions src/js/component/item-details/tabs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import cx from 'classnames';
import PropTypes from 'prop-types';
import { Fragment, useCallback, useEffect, useId, useMemo, useState } from 'react';
import { useDispatch, useSelector, shallowEqual } from 'react-redux';
import { Spinner } from 'web-common/components';
import { Spinner, Tab, Tabs } from 'web-common/components';

import Attachments from '../../component/item-details/attachments';
import EditToggleButton from '../edit-toggle-button';
Expand All @@ -13,7 +13,6 @@ import Related from '../../component/item-details/related';
import StandaloneAttachmentTabPane from '../../component/item-details/standalone-attachment';
import StandaloneNote from '../../component/item-details/standalone-note';
import Tags from '../../component/item-details/tags';
import { Tab, Tabs } from '../ui/tabs';
import { useEditMode, useFetchingState } from '../../hooks';
import { get, mapRelationsToItemKeys } from '../../utils';
import { fetchChildItems, fetchRelatedItems, } from '../../actions';
Expand Down Expand Up @@ -151,6 +150,7 @@ const ItemDetailsTabs = () => {
<Tabs
compact
activateOnFocus
as-sections={ !shouldUseTabs }
aria-label={ shouldUseTabs ? 'Item Details' : null }
>
{
Expand Down
3 changes: 1 addition & 2 deletions src/js/component/item-details/tags.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ import PropTypes from 'prop-types';
import { memo, useEffect, useCallback, useRef, useState } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import deepEqual from 'deep-equal';
import { Button, Icon } from 'web-common/components';
import { Button, Icon, TabPane } from 'web-common/components';
import { useFocusManager, usePrevious } from 'web-common/hooks';
import { isTriggerEvent, noop, pick } from 'web-common/utils';

import Editable from '../editable';
import { deduplicateByKey, get, getScrollContainerPageCount, sortByKey } from '../../utils';
import { fetchTagSuggestions, updateItem } from '../../actions';
import { TabPane } from '../ui/tabs';
import { Toolbar, ToolGroup } from '../ui/toolbars';
import { pluralize } from '../../common/format';

Expand Down
144 changes: 0 additions & 144 deletions src/js/component/ui/tabs.jsx

This file was deleted.

33 changes: 23 additions & 10 deletions src/scss/components/_tabs.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
//
// Tabs
// --------------------------------------------------

.tabs {
display: flex;
border-bottom: $border-width solid $tabs-border-color;
Expand All @@ -18,14 +14,24 @@
flex: 1 1 0;
}

a {
flex: 1 1 auto;
display: flex;
justify-content: center;
button {
align-items: center;
appearance: none;
background: none;
border: none;
color: $tab-inactive-color;
padding: 0 $tabs-padding-x;
cursor: pointer;
display: inline;
flex: 1 1 auto;
font-family: inherit;
font-size: $font-size-base;
font-weight: inherit;
height: $tabs-height;
justify-content: center;
padding: 0 $tabs-padding-x;
text-decoration: none;

@include text-truncate;

@include touch-or-bp-down(sm) {
height: $tabs-height-touch;
Expand All @@ -44,6 +50,12 @@
@include state("li.active") {
color: $tab-active-color;
box-shadow: inset 0 -1px $tab-active-color, 0 1px $tab-active-color;

@include scopedVariant(".keyboard") {
&:focus-within {
box-shadow: none;
}
}
}

@include variant(".tabs.compact") {
Expand Down Expand Up @@ -85,9 +97,10 @@
margin: 0;
line-height: $line-height-large-touch;
padding: $border-width $default-padding-x-touch;
background-color: $tab-pane-heading-bg;

@include hairline(top, $tab-pane-heading-border-color);
@include hairline(bottom, $tab-pane-heading-border-color);
background-color: $tab-pane-heading-bg;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/scss/zotero-web-library.scss
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ $scope: ".zotero-wl";
@import "../../modules/web-common/scss/icon";
@import "components/icon-extra";
@import "components/panel";
@import "components/tabs";
@import "components/tabs"; // "../../modules/web-common/scss/tabs" does not support scopedVariant and touch-specific shenanigans
@import "components/toolbar";
@import "components/touch-header";
@import "components/touch-footer";
Expand Down

0 comments on commit 9a8a57a

Please sign in to comment.