@autobusal/common 1.9.0 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Avatar.tsx +3 -2
- package/CompanyItem/styles.ts +3 -2
- package/RouteItem/styles.ts +7 -1
- package/package.json +1 -1
- package/styles.ts +51 -0
package/Avatar.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import styled from 'styled-components';
|
|
2
2
|
import { OperatorData } from '@autobusal/providers/types/operators';
|
|
3
3
|
import { AgentData } from '@autobusal/providers/types/agents';
|
|
4
|
+
import { logoBox } from './styles';
|
|
4
5
|
|
|
5
6
|
interface Props {
|
|
6
7
|
display?: OperatorData | AgentData
|
|
@@ -19,8 +20,8 @@ const Container = styled.div`
|
|
|
19
20
|
gap: 10px;
|
|
20
21
|
|
|
21
22
|
& > img {
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
${ logoBox('80px', '48px') }
|
|
24
|
+
|
|
24
25
|
border-radius: ${ props => props.theme.borderRadius };
|
|
25
26
|
}
|
|
26
27
|
`;
|
package/CompanyItem/styles.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import styled, { css } from 'styled-components';
|
|
2
2
|
import { Link } from 'react-router-dom';
|
|
3
|
+
import { logoBox } from '../styles';
|
|
3
4
|
|
|
4
5
|
export const Item = styled.div<{
|
|
5
6
|
$column: boolean
|
|
@@ -41,8 +42,8 @@ const LogoCss = css`
|
|
|
41
42
|
justify-content: center;
|
|
42
43
|
|
|
43
44
|
& > img {
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
${ logoBox('120px', '72px') }
|
|
46
|
+
|
|
46
47
|
border-radius: ${ props => props.theme.borderRadius };
|
|
47
48
|
}
|
|
48
49
|
`;
|
package/RouteItem/styles.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import styled, { css } from 'styled-components';
|
|
2
2
|
import { Link } from 'react-router-dom';
|
|
3
|
+
import { logoFit } from '../styles';
|
|
3
4
|
|
|
4
5
|
export const Container = styled.div`
|
|
5
6
|
padding: 10px;
|
|
@@ -29,8 +30,13 @@ export const Logo = styled(Link)`
|
|
|
29
30
|
border-radius: ${ props => props.theme.borderRadius };
|
|
30
31
|
|
|
31
32
|
& > img {
|
|
32
|
-
|
|
33
|
+
${ logoFit }
|
|
34
|
+
|
|
35
|
+
/* the container carries aspect-ratio: 1.35 - filling it completely is
|
|
36
|
+
what lets object-fit letterbox inside that shape, instead of the
|
|
37
|
+
image dictating its own height and spilling out of it */
|
|
33
38
|
width: 100%;
|
|
39
|
+
height: 100%;
|
|
34
40
|
}
|
|
35
41
|
`;
|
|
36
42
|
|
package/package.json
CHANGED
package/styles.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { css } from 'styled-components';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* How an operator/agent logo is displayed, everywhere.
|
|
5
|
+
*
|
|
6
|
+
* Edited: Ferjolt Ozuni - Date: 2026-07-31
|
|
7
|
+
*
|
|
8
|
+
* Logos are uploaded by operators at whatever size and shape they happen to
|
|
9
|
+
* have - tall badges, wide wordmarks, squares. Every place that rendered
|
|
10
|
+
* one set a width (or `width: 100%`) and no height and no `object-fit`, so
|
|
11
|
+
* the image was left to take whatever height its own ratio implied: inside
|
|
12
|
+
* a fixed or aspect-ratio'd box that meant it overflowed and was visibly
|
|
13
|
+
* cropped, and in a flex row it stretched its neighbours around.
|
|
14
|
+
*
|
|
15
|
+
* `object-fit: contain` is the whole fix. It scales the image down until it
|
|
16
|
+
* fits INSIDE the box in its own aspect ratio, never cropping and never
|
|
17
|
+
* distorting. Whatever room is left over stays empty - deliberately
|
|
18
|
+
* transparent rather than a colour, so the logo sits on whatever the
|
|
19
|
+
* surrounding card already uses and dark and light themes both work without
|
|
20
|
+
* a second rule.
|
|
21
|
+
*
|
|
22
|
+
* The box needs BOTH dimensions for this to mean anything: with only a
|
|
23
|
+
* width there is no leftover space for `contain` to preserve, and the
|
|
24
|
+
* behaviour collapses back to the original bug. Callers pass the size.
|
|
25
|
+
*
|
|
26
|
+
* `object-position: center` is explicit rather than relied upon - it is the
|
|
27
|
+
* default, but the whole point here is that nothing about the framing is
|
|
28
|
+
* left to chance.
|
|
29
|
+
*/
|
|
30
|
+
export const logoFit = css`
|
|
31
|
+
display: block;
|
|
32
|
+
object-fit: contain;
|
|
33
|
+
object-position: center;
|
|
34
|
+
|
|
35
|
+
/* no fill, so the logo adopts whatever surface it is placed on */
|
|
36
|
+
background: transparent;
|
|
37
|
+
`;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* A complete logo box: fits the image inside the given dimensions without
|
|
41
|
+
* cropping or stretching it.
|
|
42
|
+
*
|
|
43
|
+
* Pass the size the layout wants; the image keeps its own proportions
|
|
44
|
+
* within it.
|
|
45
|
+
*/
|
|
46
|
+
export const logoBox = (width: string, height: string) => css`
|
|
47
|
+
${ logoFit }
|
|
48
|
+
|
|
49
|
+
width: ${ width };
|
|
50
|
+
height: ${ height };
|
|
51
|
+
`;
|