Skip to content
This repository has been archived by the owner on Sep 9, 2024. It is now read-only.

Commit

Permalink
feat: enhancements and fixes (#810)
Browse files Browse the repository at this point in the history
  • Loading branch information
KaneFreeman authored May 18, 2023
1 parent f64f202 commit 6d1ce60
Show file tree
Hide file tree
Showing 46 changed files with 352 additions and 237 deletions.
1 change: 1 addition & 0 deletions packages/core/dev-test/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ collections:
create: true
editor:
frame: false
size: half
fields:
- label: Question
name: title
Expand Down
22 changes: 19 additions & 3 deletions packages/core/src/backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
hasI18n,
} from './lib/i18n';
import { getBackend, invokeEvent } from './lib/registry';
import { sanitizeChar } from './lib/urlHelper';
import { joinUrlPath, sanitizeChar } from './lib/urlHelper';
import {
CURSOR_COMPATIBILITY_SYMBOL,
Cursor,
Expand All @@ -39,7 +39,11 @@ import {
selectInferredField,
selectMediaFolders,
} from './lib/util/collection.util';
import { selectMediaFilePath, selectMediaFilePublicPath } from './lib/util/media.util';
import {
DRAFT_MEDIA_FILES,
selectMediaFilePath,
selectMediaFilePublicPath,
} from './lib/util/media.util';
import { selectCustomPath, slugFromCustomPath } from './lib/util/nested.util';
import { set } from './lib/util/object.util';
import { dateParsers, expandPath, extractTemplateVars } from './lib/widgets/stringTemplate';
Expand Down Expand Up @@ -84,7 +88,19 @@ function updateAssetProxies(
// update media files path based on entry path
const oldPath = asset.path;
entryDraft.entry.path = path;
const newPath = selectMediaFilePath(config, collection, entryDraft.entry, oldPath, asset.field);

const folderPath = joinUrlPath(
collection && 'folder' in collection ? collection.folder : '',
DRAFT_MEDIA_FILES,
);

const newPath = selectMediaFilePath(
config,
collection,
entryDraft.entry,
oldPath.replace(folderPath, ''),
asset.field,
);
asset.path = newPath;
});
}
Expand Down
41 changes: 21 additions & 20 deletions packages/core/src/components/collections/CollectionSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,25 +146,25 @@ const CollectionSearch = ({
type="text"
id="first_name"
className="
block
w-full
p-1.5
pl-10
text-sm
text-gray-900
border
border-gray-300
rounded-lg
bg-gray-50
focus-visible:outline-none
focus:ring-4
focus:ring-gray-200
dark:bg-gray-700
dark:border-gray-600
dark:placeholder-gray-400
dark:text-white
dark:focus:ring-slate-700
"
block
w-full
p-1.5
pl-10
text-sm
text-gray-800
border
border-gray-300
rounded-lg
bg-gray-50
focus-visible:outline-none
focus:ring-4
focus:ring-gray-200
dark:bg-gray-700
dark:border-gray-600
dark:placeholder-gray-400
dark:text-white
dark:focus:ring-slate-700
"
placeholder={t('collection.sidebar.searchAll')}
onKeyDown={handleKeyDown}
onBlur={handleBlur}
Expand All @@ -185,14 +185,15 @@ const CollectionSearch = ({
rounded-md
bg-white
text-base
shadow-lg
shadow-md
ring-1
ring-black
ring-opacity-5
focus:outline-none
sm:text-sm
z-40
dark:bg-slate-700
dark:shadow-lg
"
>
<div
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/components/collections/FilterControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const FilterControl = ({
/>
<label
htmlFor={labelId}
className="ml-2 text-sm font-medium text-gray-900 dark:text-gray-300"
className="ml-2 text-sm font-medium text-gray-800 dark:text-gray-300"
>
{viewFilter.label}
</label>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,6 @@ const EntryListingCardGrid: FC<EntryListingCardGridProps> = ({
}, []);

const getDefaultHeight = useCallback((data?: CollectionEntryData) => {
console.log(
'DEFAULT HEIGHT',
data,
isNotNullish(data?.imageFieldName)
? COLLECTION_CARD_HEIGHT
: COLLECTION_CARD_HEIGHT_WITHOUT_IMAGE,
);
return isNotNullish(data?.imageFieldName)
? COLLECTION_CARD_HEIGHT
: COLLECTION_CARD_HEIGHT_WITHOUT_IMAGE;
Expand Down Expand Up @@ -187,22 +180,13 @@ const EntryListingCardGrid: FC<EntryListingCardGridProps> = ({

if (cardHeights[i] > rowHeight && cardHeights[i]) {
rowHeight = cardHeights[i] + COLLECTION_CARD_MARGIN;

console.log(
'HEIGHT @index',
i,
cardHeights[i],
cardHeights[i] + COLLECTION_CARD_MARGIN,
);
}
}

if (rowHeight === 0) {
rowHeight = getDefaultHeight() + COLLECTION_CARD_MARGIN;
}

console.log('HEIGHT', index, rowHeight);

return rowHeight;
}}
width={width}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,12 @@ const EntryListingTable: FC<EntryListingTableProps> = ({
overflow-hidden
p-1.5
bg-white
shadow-sm
border
border-gray-100
dark:bg-slate-800
dark:border-gray-700/40
dark:shadow-md
rounded-xl
"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const Autocomplete = function <T>(
min-h-8
p-0
w-full
text-gray-900
text-gray-800
dark:text-gray-100
"
data-testid="autocomplete-input-wrapper"
Expand Down Expand Up @@ -99,7 +99,7 @@ const Autocomplete = function <T>(
dark:text-gray-500
`
: `
text-gray-900
text-gray-800
dark:text-gray-100
`,
)}
Expand Down Expand Up @@ -144,18 +144,19 @@ const Autocomplete = function <T>(
bg-white
py-1
text-base
shadow-lg
shadow-md
ring-1
ring-black
ring-opacity-5
focus:outline-none
sm:text-sm
z-30
dark:bg-slate-700
dark:shadow-lg
`}
>
{options.length === 0 ? (
<div className="relative cursor-default select-none py-2 px-4 text-gray-700">
<div className="relative cursor-default select-none py-2 px-4 text-gray-800">
Nothing found.
</div>
) : (
Expand All @@ -179,7 +180,7 @@ const Autocomplete = function <T>(
pl-10
pr-4
cursor-pointer
text-gray-900
text-gray-800
dark:text-gray-100
`,
(selected || active) &&
Expand Down
8 changes: 5 additions & 3 deletions packages/core/src/components/common/card/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ const Card = ({ children, className }: CardProps) => {
<div
className={classNames(
`
bg-white border
border-gray-200
bg-white
border
border-gray-100
rounded-lg
shadow-md
shadow-sm
dark:bg-slate-800
dark:border-gray-700/40
dark:shadow-md
flex
flex-col
h-full
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/components/common/card/CardContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ interface CardContentProps {
}

const CardContent = ({ children }: CardContentProps) => {
return <p className="w-full p-5 font-normal text-gray-700 dark:text-gray-300">{children}</p>;
return <p className="w-full p-5 font-normal text-gray-800 dark:text-gray-300">{children}</p>;
};

export default CardContent;
2 changes: 1 addition & 1 deletion packages/core/src/components/common/card/CardHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ interface CardHeaderProps {

const CardHeader = ({ children }: CardHeaderProps) => {
return (
<h5 className="mb-2 text-2xl font-bold tracking-tight text-gray-900 dark:text-white">
<h5 className="mb-2 text-2xl font-bold tracking-tight text-gray-800 dark:text-white">
{children}
</h5>
);
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/components/common/menu/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,15 @@ const Menu = ({
rounded-md
bg-white
dark:bg-slate-800
shadow-lg
shadow-md
border
border-gray-200
focus:outline-none
divide-y
divide-gray-100
dark:border-gray-700
dark:divide-gray-600
dark:shadow-lg
`,
onClick: handleClose,
},
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/components/common/menu/MenuItemButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ const MenuItemButton = ({
items-center
justify-between
cursor-pointer
dark:disabled:text-gray-700
dark:disabled:text-gray-800
`,
color === 'default' &&
`
text-gray-700
text-gray-800
dark:text-gray-300
hover:bg-gray-200
dark:hover:bg-slate-600
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/components/common/menu/MenuItemLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const MenuItemLink = ({
px-4
py-2
text-sm
text-gray-700
text-gray-800
dark:text-gray-300
w-full
text-left
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/components/common/pill/Pill.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const Pill: FC<PillProps> = ({
`
: `
bg-gray-200
text-gray-900
text-gray-800
dark:bg-gray-700
dark:text-gray-100
`;
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/components/common/select/Option.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const Option = function <T>({
py-2
px-4
cursor-pointer
text-gray-900
text-gray-800
hover:bg-blue-500
dark:text-gray-100
`,
Expand Down
5 changes: 3 additions & 2 deletions packages/core/src/components/common/select/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ const Select = forwardRef(
px-4
py-1.5
w-full
text-gray-900
text-gray-800
dark:text-gray-100
`,
disabled &&
Expand All @@ -154,14 +154,15 @@ const Select = forwardRef(
bg-white
py-1
text-base
shadow-lg
shadow-md
ring-1
ring-black
ring-opacity-5
focus:outline-none
sm:text-sm
z-50
dark:bg-slate-700
dark:shadow-lg
`,
style: { width },
disablePortal: false,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/components/common/switch/Switch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const Switch = forwardRef<HTMLInputElement | null, SwitchProps>(
ml-3
text-sm
font-medium
text-gray-900
text-gray-800
dark:text-gray-300
"
>
Expand Down
3 changes: 1 addition & 2 deletions packages/core/src/components/common/table/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@ const TableCell = ({ columns, children }: TableCellProps) => {
return (
<div
className="
shadow-md
z-[2]
"
>
<table className="w-full text-sm text-left text-gray-500 dark:text-gray-300">
<thead className="text-xs">
<tr>
<tr className="shadow-sm">
{columns.map((column, index) => (
<TableHeaderCell key={index}>{column}</TableHeaderCell>
))}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/components/common/table/TableCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const TableCell = ({ children, emphasis = false, to, shrink = false }: TableCell
text-gray-500
dark:text-gray-300
`,
emphasis && 'font-medium text-gray-900 whitespace-nowrap dark:text-white',
emphasis && 'font-medium text-gray-800 whitespace-nowrap dark:text-white',
shrink && 'w-0',
)}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,13 @@ const TableHeaderCell = ({ children }: TableHeaderCellProps) => {
className="
px-4
py-3
text-gray-900
text-gray-800
border-gray-100
border-b
bg-white
dark:text-white
dark:border-gray-700
dark:bg-slate-800
shadow-sm
text-[14px]
"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const TextArea = forwardRef<HTMLInputElement | null, TextAreaProps>(
outline-none
text-sm
font-medium
text-gray-900
text-gray-800
dark:text-gray-100
disabled:text-gray-300
dark:disabled:text-gray-500
Expand Down
Loading

0 comments on commit 6d1ce60

Please sign in to comment.