Skip to content

Commit 19301b7

Browse files
committed
Docs: Add initial attach
1 parent 787fcf0 commit 19301b7

File tree

4 files changed

+72
-0
lines changed

4 files changed

+72
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
title: 'Behavior - Attach'
3+
shortTitle: 'Attach'
4+
id: 'query-attach-behavior'
5+
category: 'Query'
6+
subcategory: 'Standard Plugins'
7+
exampleType: 'component'
8+
description: 'Position an element relative to another element'
9+
tags: ['query', 'plugin', 'behavior', 'attach', 'position']
10+
tip: 'Attach is a modern browser spec that automatically lets you position elements relative to another element'
11+
---
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
:root {
2+
--box-size: 50vw;
3+
--box-size-min: 200px;
4+
5+
--square-size: 10vw;
6+
--square-size-min: 50px;
7+
8+
--square-margin: max(var(--square-size), var(--square-size-min)) auto;
9+
10+
}
11+
12+
.box {
13+
position: relative;
14+
margin: var(--square-margin);
15+
background: var(--blue-0);
16+
background-image: var(--angled-gradient);
17+
border: var(--blue-border);
18+
box-shadow: var(--shadow);
19+
width: var(--box-size);
20+
height: var(--box-size);
21+
min-width: var(--box-size-min);
22+
min-height: var(--box-size-min);
23+
}
24+
25+
.square {
26+
background-color: var(--red-5);
27+
border: var(--red-border);
28+
background-image: var(--angled-gradient);
29+
width: var(--square-size);
30+
height: var(--square-size);
31+
min-width: var(--square-size-min);
32+
min-height: var(--square-size-min);
33+
position: absolute;
34+
font-size: 9px;
35+
padding: 5px;
36+
font-weight: bold;
37+
color: var(--red-text-color);
38+
box-shadow: var(--shadow);
39+
text-align: center;
40+
align-content: center;
41+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<div class="box"></div>
2+
<div class="square" data-position="top left">Top Left</div>
3+
<div class="square" data-position="top">Top</div>
4+
<div class="square" data-position="top right">Top Right</div>
5+
<div class="square" data-position="right top">Right Top</div>
6+
<div class="square" data-position="right">Right</div>
7+
<div class="square" data-position="right bottom">Right Bottom</div>
8+
<div class="square" data-position="bottom right">Bottom Right</div>
9+
<div class="square" data-position="bottom">Bottom</div>
10+
<div class="square" data-position="bottom left">Bottom Left</div>
11+
<div class="square" data-position="left bottom">Left Bottom</div>
12+
<div class="square" data-position="left">Left</div>
13+
<div class="square" data-position="left top">Left Top</div>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { Attach, Transition } from '@semantic-ui/core';
2+
import { $ } from '@semantic-ui/query';
3+
4+
// initialize popup inside page
5+
$('.square').attach({
6+
to: '.box',
7+
});

0 commit comments

Comments
 (0)