fix: Replace max_height with height (#1539)
* fix: Replace `max_height` with `height` BREAKING CHANGE: This entirely removes `min_height`, and replaces `max_height` with `height`. The behavior is obviously not exactly the same, but the prior behavior did not actually work correctly. CSS does not limit the height of child elements that are `100%` of their parents height if the parent does not have an explicit height set (this caused spillage over the set max height). As such, it's simpler to just allow the user to set the actual height of the card should they need to do so, with a (hopefully) minor loss of flexibility. * Test fixes
This commit is contained in:
@@ -209,8 +209,7 @@ describe('StyleManager', () => {
|
||||
vi.mocked(api.getConfigManager().getConfig).mockReturnValue(
|
||||
createConfig({
|
||||
dimensions: {
|
||||
max_height: '800px',
|
||||
min_height: '400px',
|
||||
height: '800px',
|
||||
},
|
||||
}),
|
||||
);
|
||||
@@ -218,8 +217,7 @@ describe('StyleManager', () => {
|
||||
|
||||
manager.setMinMaxHeight();
|
||||
|
||||
expect(element.style.getPropertyValue('--frigate-card-min-height')).toBe('400px');
|
||||
expect(element.style.getPropertyValue('--frigate-card-max-height')).toBe('800px');
|
||||
expect(element.style.getPropertyValue('--frigate-card-height')).toBe('800px');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
import { CallServiceActionConfig } from '@dermotduffy/custom-card-helpers';
|
||||
import {
|
||||
CallServiceActionConfig,
|
||||
PerformActionActionConfig,
|
||||
} from '@dermotduffy/custom-card-helpers';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import {
|
||||
copyConfig,
|
||||
@@ -21,7 +24,6 @@ import {
|
||||
import { PTZControlAction } from '../../src/config/ptz';
|
||||
import {
|
||||
Actions,
|
||||
PerformActionActionConfig,
|
||||
RawFrigateCardConfig,
|
||||
frigateCardConfigSchema,
|
||||
} from '../../src/config/types';
|
||||
@@ -3313,7 +3315,7 @@ describe('should handle version specific upgrades', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('call-service -> perform-action', () => {
|
||||
it('rename call-service -> perform-action', () => {
|
||||
const config = {
|
||||
type: 'custom:frigate-card',
|
||||
cameras: [{ camera_entity: 'camera.office' }],
|
||||
@@ -3367,5 +3369,41 @@ describe('should handle version specific upgrades', () => {
|
||||
});
|
||||
postUpgradeChecks(config);
|
||||
});
|
||||
|
||||
it('rename dimensions.max_height -> dimensions.height', () => {
|
||||
const config = {
|
||||
type: 'custom:frigate-card',
|
||||
cameras: [{ camera_entity: 'camera.office' }],
|
||||
dimensions: {
|
||||
max_height: '500px',
|
||||
},
|
||||
};
|
||||
expect(upgradeConfig(config)).toBeTruthy();
|
||||
expect(config).toEqual({
|
||||
type: 'custom:frigate-card',
|
||||
cameras: [{ camera_entity: 'camera.office' }],
|
||||
dimensions: {
|
||||
height: '500px',
|
||||
},
|
||||
});
|
||||
postUpgradeChecks(config);
|
||||
});
|
||||
|
||||
it('delete dimensions.min_height', () => {
|
||||
const config = {
|
||||
type: 'custom:frigate-card',
|
||||
cameras: [{ camera_entity: 'camera.office' }],
|
||||
dimensions: {
|
||||
min_height: '100px',
|
||||
},
|
||||
};
|
||||
expect(upgradeConfig(config)).toBeTruthy();
|
||||
expect(config).toEqual({
|
||||
type: 'custom:frigate-card',
|
||||
cameras: [{ camera_entity: 'camera.office' }],
|
||||
dimensions: {},
|
||||
});
|
||||
postUpgradeChecks(config);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -55,8 +55,7 @@ describe('config defaults', () => {
|
||||
dimensions: {
|
||||
aspect_ratio: [16, 9],
|
||||
aspect_ratio_mode: 'dynamic',
|
||||
max_height: '100vh',
|
||||
min_height: '100px',
|
||||
height: 'auto',
|
||||
},
|
||||
image: {
|
||||
mode: 'auto',
|
||||
|
||||
Reference in New Issue
Block a user