Skip to content

Commit 75a00d1

Browse files
kangcalebmshabarov
authored andcommitted
feat: Add Flow component for code Html element #20832 (#21580)
* Extended Tag, add Code.java, relevant tests * Removed implements clicknotifier + javadoc * alphabetical order in tag, better javadoc (cherry picked from commit 547bc83)
1 parent 25ab79e commit 75a00d1

File tree

3 files changed

+68
-0
lines changed
  • flow-html-components/src
  • flow-server/src/main/java/com/vaadin/flow/component

3 files changed

+68
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package com.vaadin.flow.component.html;
2+
3+
import com.vaadin.flow.component.Component;
4+
import com.vaadin.flow.component.HtmlContainer;
5+
import com.vaadin.flow.component.Tag;
6+
7+
/**
8+
* Component representing a <code>&lt;code&gt;</code> element.
9+
*
10+
* @author Vaadin Ltd
11+
* @since 25.0
12+
*/
13+
@Tag(Tag.CODE)
14+
public class Code extends HtmlContainer {
15+
16+
/**
17+
* Creates a new empty code component.
18+
*/
19+
public Code() {
20+
super();
21+
}
22+
23+
/**
24+
* Creates a new code component with the given child components.
25+
*
26+
* @param components
27+
* the child components
28+
*/
29+
public Code(Component... components) {
30+
super(components);
31+
}
32+
33+
/**
34+
* Creates a new code component with the given text.
35+
*
36+
* @param text
37+
* the text
38+
*/
39+
public Code(String text) {
40+
super();
41+
setText(text);
42+
}
43+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.vaadin.flow.component.html;
2+
3+
import org.junit.Test;
4+
5+
public class CodeTest extends ComponentTest {
6+
// Actual test methods in super class
7+
8+
@Override
9+
protected void addProperties() {
10+
// Component defines no new properties
11+
}
12+
13+
@Test
14+
@Override
15+
public void testHasAriaLabelIsNotImplemented() {
16+
// Don't use aria-label or aria-labelledby on any other non-interactive
17+
// content such as p, legend, li, or ul, because it is ignored.
18+
// Source: https://www.w3.org/TR/using-aria/#label-support
19+
super.testHasAriaLabelIsNotImplemented();
20+
}
21+
}

flow-server/src/main/java/com/vaadin/flow/component/Tag.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@
5858
* Tag for an <code>&lt;caption&gt;</code>.
5959
*/
6060
String CAPTION = "caption";
61+
/**
62+
* Tag for a <code>&lt;code&gt;</code>.
63+
*/
64+
String CODE = "code";
6165
/**
6266
* Tag for an <code>&lt;dd&gt;</code>.
6367
*/

0 commit comments

Comments
 (0)