Skip to content

Commit

Permalink
chore: Rename 'align' attribute to 'text_align'
Browse files Browse the repository at this point in the history
  • Loading branch information
marc2332 committed Oct 15, 2023
1 parent 1b8edd7 commit c069d98
Show file tree
Hide file tree
Showing 16 changed files with 33 additions and 33 deletions.
8 changes: 4 additions & 4 deletions book/src/guides/font_style.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Learn how the font style attributes work.
- [`color`](#color)
- [`font_family`](#font_family)
- [`font_size`](#font_size)
- [`align`](#align)
- [`text_align`](#text_align)
- [`font_style`](#font_style)
- [`font_weight`](#font_weight)
- [`font_width`](#font_width)
Expand Down Expand Up @@ -97,9 +97,9 @@ fn app(cx: Scope) -> Element {

Compatible elements: [`label`](/guides/elements.html#label), [`paragraph`](/guides/elements.html#paragraph-and-text), [`text`](/guides/elements.html#paragraph-and-text)

### align
### text_align

You can change the alignment of the text using the `align` attribute.
You can change the alignment of the text using the `text_align` attribute.

Accepted values: `center`, `end`, `justify`, `left`, `right`, `start`

Expand All @@ -109,7 +109,7 @@ Example
fn app(cx: Scope) -> Element {
render!(
label {
align: "right",
text_align: "right",
"Hello, World!"
}
)
Expand Down
2 changes: 1 addition & 1 deletion crates/components/src/dropdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ where
height: "auto",
padding: "7",
label {
align: "center",
text_align: "center",
"{selected}"
}
rect {
Expand Down
2 changes: 1 addition & 1 deletion crates/components/src/network_image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ pub fn NetworkImage<'a>(cx: Scope<'a, NetworkImageProps<'a>>) -> Element<'a> {
width: "{width}",
display: "center",
label {
align: "center",
text_align: "center",
"Error"
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/components/src/progress_bar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ pub fn ProgressBar(cx: Scope<ProgressBarProps>) -> Element {
if show_progress {
rsx!(
label {
align: "center",
text_align: "center",
width: "100%",
color: "white",
max_lines: "1",
Expand Down
2 changes: 1 addition & 1 deletion crates/devtools/src/tab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ pub fn TabButton<'a>(cx: Scope<'a, TabButtonProps<'a>>) -> Element<'a> {
color: "{color}",
padding: "7.5",
label {
align: "center",
text_align: "center",
height: "100%",
width: "100%",
content
Expand Down
8 changes: 4 additions & 4 deletions crates/devtools/src/tabs/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub fn NodeInspectorLayout(cx: Scope, node_id: NodeId) -> Element {
height: "25",
label {
width: "100%",
align: "center",
text_align: "center",
"{paddings.top()}"
}
}
Expand All @@ -72,7 +72,7 @@ pub fn NodeInspectorLayout(cx: Scope, node_id: NodeId) -> Element {
height: "100%",
label {
width: "100%",
align: "center",
text_align: "center",
"{paddings.left()}"
}
}
Expand All @@ -94,7 +94,7 @@ pub fn NodeInspectorLayout(cx: Scope, node_id: NodeId) -> Element {
height: "100%",
label {
width: "100%",
align: "center",
text_align: "center",
"{paddings.right()}"
}
}
Expand All @@ -106,7 +106,7 @@ pub fn NodeInspectorLayout(cx: Scope, node_id: NodeId) -> Element {
height: "25",
label {
width: "100%",
align: "center",
text_align: "center",
"{paddings.bottom()}"
}
}
Expand Down
4 changes: 2 additions & 2 deletions crates/elements/src/elements.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ builder_constructors! {
font_style: String,
font_weight: String,
font_width: String,
align: String,
text_align: String,
max_lines: String,
rotate: String,
role: String,
Expand All @@ -225,7 +225,7 @@ builder_constructors! {
min_width: String,
max_height: String,
max_width: String,
align: String,
text_align: String,
cursor_index: String,
max_lines: String,
cursor_color: String,
Expand Down
4 changes: 2 additions & 2 deletions crates/layout/src/measurer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ pub fn create_text(
let font_style = &*node.get::<FontStyleState>().unwrap();

let mut paragraph_style = ParagraphStyle::default();
paragraph_style.set_text_align(font_style.align);
paragraph_style.set_text_align(font_style.text_align);
paragraph_style.set_max_lines(font_style.max_lines);
paragraph_style.set_replace_tab_characters(true);
paragraph_style.set_text_style(&font_style.into());
Expand Down Expand Up @@ -130,7 +130,7 @@ pub fn create_paragraph(
let node_cursor_settings = &*node.get::<CursorSettings>().unwrap();

let mut paragraph_style = ParagraphStyle::default();
paragraph_style.set_text_align(font_style.align);
paragraph_style.set_text_align(font_style.text_align);
paragraph_style.set_max_lines(font_style.max_lines);
paragraph_style.set_replace_tab_characters(true);

Expand Down
10 changes: 5 additions & 5 deletions crates/state/src/font_style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub struct FontStyleState {
pub decoration: Decoration,
pub word_spacing: f32,
pub letter_spacing: f32,
pub align: TextAlign,
pub text_align: TextAlign,
pub max_lines: Option<usize>,
pub text_overflow: TextOverflow,
}
Expand Down Expand Up @@ -85,7 +85,7 @@ impl Default for FontStyleState {
thickness_multiplier: 1.0, // Defaults to 0.0, even though 0.0 won't render anything
..Decoration::default()
},
align: TextAlign::default(),
text_align: TextAlign::default(),
max_lines: None,
text_overflow: TextOverflow::default(),
}
Expand Down Expand Up @@ -184,10 +184,10 @@ impl State<CustomAttributeValues> for FontStyleState {
}
}
}
"align" => {
"text_align" => {
if let Some(value) = attr.value.as_text() {
if let Ok(align) = TextAlign::parse(value) {
font_style.align = align;
if let Ok(text_align) = TextAlign::parse(value) {
font_style.text_align = text_align;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/animation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ fn app(cx: Scope) -> Element {
onclick: anim,
label {
font_size: "30",
align: "center",
text_align: "center",
color: "white",
"Click to move"
}
Expand Down
2 changes: 1 addition & 1 deletion examples/custom_font.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fn app(cx: Scope) -> Element {
width: "100%",
font_size: "20",
font_family: "Sansita Swashed",
align: "center",
text_align: "center",
"This font is called Sansita Swashed"
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/gesture_area.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ fn app(cx: Scope) -> Element {
direction: "vertical",
display: "center",
label {
align: "center",
text_align: "center",
width: "100%",
font_size: "70",
"{gesture}"
Expand Down
2 changes: 1 addition & 1 deletion examples/paragraph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fn app(cx: Scope) -> Element {
height: "75%",
paragraph {
width: "100%",
align: "right",
text_align: "right",
text {
color: "rgb(240, 50, 100)",
"{loremipsum.repeat(2)}"
Expand Down
12 changes: 6 additions & 6 deletions examples/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,42 +76,42 @@ fn app(cx: Scope) -> Element {
label {
font_size: "18",
font_family: "Inter",
align: "right",
text_align: "right",
width: "100%",
"Right align"
}
label {
font_size: "18",
font_family: "Inter",
align: "center",
text_align: "center",
width: "100%",
"Center align"
}
label {
font_size: "18",
font_family: "Inter",
align: "justify",
text_align: "justify",
width: "100%",
"Justify align"
}
label {
font_size: "18",
font_family: "Inter",
align: "end",
text_align: "end",
width: "100%",
"End align"
}
label {
font_size: "18",
font_family: "Inter",
align: "start",
text_align: "start",
width: "100%",
"Start align"
}
label {
font_size: "18",
font_family: "Inter",
align: "left",
text_align: "left",
width: "100%",
"Left align"
}
Expand Down
2 changes: 1 addition & 1 deletion examples/tic_tac_toe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ fn app(cx: Scope) -> Element {
label {
height: "20",
width: "100%",
align: "center",
text_align: "center",
"{message}"
}
for (n_row, row) in board.read().board.iter().enumerate() {
Expand Down
2 changes: 1 addition & 1 deletion examples/transition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ fn app(cx: Scope) -> Element {
label {
width: "100%",
font_size: "30",
align: "center",
text_align: "center",
color: "{text}",
"Click to move"
}
Expand Down

0 comments on commit c069d98

Please sign in to comment.