Skip to content

Commit 6f9dea8

Browse files
author
Adam Raider
committed
fix: add caption element for media
1 parent 0eddf53 commit 6f9dea8

File tree

5 files changed

+69
-7
lines changed

5 files changed

+69
-7
lines changed

docs/components/image.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ label: Component
33
title: Image
44
---
55

6-
<page-intro>The `image` and `bg` components provide an easy way to add fixed aspect-ratio graphics to your site.</page-intro>
6+
<page-intro>The `image` and `bg` components provide an easy way to add fixed aspect-ratio graphics to your site. Images can have an optional \``.ray-caption`\` element to add additional context to specific pieces of media they accompany across the system.</page-intro>
77

88
<component
9-
name="Image 16x9"
9+
name="Image 16x9 with caption"
1010
component="image"
1111
variation="image--16by9"
1212
>
@@ -30,8 +30,8 @@ title: Image
3030

3131
Use these modifiers with `.ray-image` or `.ray-bg` classes.
3232

33-
| Selector | Description |
34-
| ----------------- | --------------------------------- |
35-
| .ray-image--3by4 | Selector for 3 by 4 aspect ratio |
36-
| .ray-image--16by9 | Selector for 16 by 9 aspect ratio |
37-
| .ray-image--4By3 | Selector for 4 By 3 aspect ratio |
33+
| Selector | Description |
34+
| ----------------------- | --------------------------------- |
35+
| .ray-{image\|bg}--3by4 | Selector for 3 by 4 aspect ratio |
36+
| .ray-{image\|bg}--16by9 | Selector for 16 by 9 aspect ratio |
37+
| .ray-{image\|bg}--4By3 | Selector for 4 By 3 aspect ratio |

docs/html/image/image--16by9.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,10 @@
33
class="ray-bg ray-bg--16by9"
44
style="background-image: url(https://source.unsplash.com/random/400x300?minimalist);"
55
></div>
6+
7+
<!-- optional caption element -->
8+
<div class="ray-caption">
9+
Vangelis Drake Equation explorations venture Rig Veda encyclopaedia
10+
galactica.
11+
</div>
612
</div>

docs/html/image/image--4by3.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,9 @@
33
class="ray-bg ray-bg--4by3"
44
style="background-image: url(https://source.unsplash.com/random/800x400?minimalist);"
55
></div>
6+
<!-- optional caption element -->
7+
<div class="ray-caption">
8+
Consciousness are creatures of the cosmos rings of Uranus another world
9+
colonies concept of the number one.
10+
</div>
611
</div>

packages/core/src/components/image/_image.scss

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,22 @@
1818
}
1919
}
2020

21+
.#{$ray-class-prefix}caption {
22+
font-size: 0.75rem;
23+
line-height: 1.25rem;
24+
max-height: 2.5rem;
25+
font-family: $ray-font-stack-mono;
26+
text-transform: uppercase;
27+
overflow: hidden;
28+
text-overflow: -o-ellipsis-lastline;
29+
text-overflow: ellipsis;
30+
text-align: right;
31+
display: -webkit-box;
32+
-webkit-line-clamp: 2;
33+
-webkit-box-orient: vertical;
34+
margin-top: $ray-spacing-xs;
35+
}
36+
2137
.#{$ray-class-prefix}image {
2238
@include image;
2339

packages/core/stories/image.stories.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,39 @@ storiesOf('Image', module)
3737
}}
3838
/>
3939
</div>
40+
))
41+
.add('img with caption', () => (
42+
<div style={{ maxWidth: '500px' }}>
43+
<div className="ray-image ray-image--16by9">
44+
<img src={getPlaceholderURL('800x800')} />
45+
</div>
46+
<div className="ray-caption">
47+
12pt apercu mono caption relating to this image
48+
</div>
49+
</div>
50+
))
51+
.add('img with long caption', () => (
52+
<div style={{ maxWidth: '500px' }}>
53+
<div className="ray-image ray-image--16by9">
54+
<img src={getPlaceholderURL('800x800')} />
55+
</div>
56+
<div className="ray-caption">
57+
12pt apercu mono caption relating to this image but the caption is
58+
longer than something ideal and maybe it has for some reason scaled
59+
</div>
60+
</div>
61+
))
62+
.add('bg with caption', () => (
63+
<div style={{ maxWidth: '400px' }}>
64+
<div
65+
className="ray-bg ray-bg--3by4"
66+
style={{
67+
backgroundImage: `url(${getPlaceholderURL('800x1200')})`
68+
}}
69+
/>
70+
<div className="ray-caption">
71+
12pt apercu mono caption relating to this image but the caption is
72+
longer than something ideal and maybe it has for some reason scaled
73+
</div>
74+
</div>
4075
));

0 commit comments

Comments
 (0)