[GH-ISSUE #138] Add attributed strings from libui-node 0.2.0 #84

Closed
opened 2026-05-05 11:39:56 -06:00 by gitea-mirror · 4 comments
Owner
Originally created by @kusti8 on GitHub (May 19, 2018). Original GitHub issue: https://github.com/kusti8/proton-native/issues/138 https://github.com/parro-it/libui-node/blob/master/docs/attributedstring.md
Author
Owner

@mischnic commented on GitHub (May 19, 2018):

They can only be drawn inside an Area (see https://github.com/parro-it/libui-node/blob/master/examples/text.js).

My thoughts: There should be an Area.Text element but also an FancyText element (a better name is to be found) which creates an area internally (if there is no parent FancyText).
The attributes get inherited and specified like in react native (https://facebook.github.io/react-native/docs/text.html).

<FancyText style={{color: "red"}}>
    Some red text
    <FancyText style={{fontSize: 5}}>
        Some smaller red text
   </FancyText>
</FancyText>

Attributes:
fontSize, color, fontWeight, textAlign (only possible for top level), fontFamily, underline (+color), background color, bold/italic

<!-- gh-comment-id:390420309 --> @mischnic commented on GitHub (May 19, 2018): They can only be drawn inside an Area (see https://github.com/parro-it/libui-node/blob/master/examples/text.js). My thoughts: There should be an `Area.Text` element but also an `FancyText` element (a better name is to be found) which creates an area internally (if there is no parent `FancyText`). The attributes get inherited and specified like in react native (https://facebook.github.io/react-native/docs/text.html). ```jsx <FancyText style={{color: "red"}}> Some red text <FancyText style={{fontSize: 5}}> Some smaller red text </FancyText> </FancyText> ``` Attributes: fontSize, color, fontWeight, textAlign (only possible for top level), fontFamily, underline (+color), background color, bold/italic
Author
Owner

@kusti8 commented on GitHub (May 19, 2018):

Sounds good. Then FancyText would just be a wrapper for Area on the outer, and then Area.Text.

<!-- gh-comment-id:390420862 --> @kusti8 commented on GitHub (May 19, 2018): Sounds good. Then `FancyText` would just be a wrapper for `Area` on the outer, and then `Area.Text`.
Author
Owner

@mischnic commented on GitHub (May 19, 2018):

EDIT: Yes


I misread your post

Yes, but this has be prevented:

<FancyText style={{color: "red"}}>
    Some red text
    <FancyText style={{fontSize: 5}}>
        Some smaller red text
   </FancyText>
</FancyText>

---->

<Area>
  <Area.Text style={{color: "red"}}>
    Some red text
    <Area> !!!!
      <Area.Text style={{fontSize: 5}}>
        Some smaller red text
      </Area.Text>
    </Area> !!!!
  </Area.Text>
</Area>
<!-- gh-comment-id:390422434 --> @mischnic commented on GitHub (May 19, 2018): **EDIT:** Yes --- *I misread your post* Yes, but this has be prevented: ```jsx <FancyText style={{color: "red"}}> Some red text <FancyText style={{fontSize: 5}}> Some smaller red text </FancyText> </FancyText> ----> <Area> <Area.Text style={{color: "red"}}> Some red text <Area> !!!! <Area.Text style={{fontSize: 5}}> Some smaller red text </Area.Text> </Area> !!!! </Area.Text> </Area> ```
Author
Owner

@mischnic commented on GitHub (May 20, 2018):

Proof of concept at https://github.com/mischnic/proton-native/tree/font:

bildschirmfoto 2018-05-20 um 14 00 30

class Example extends Component {
  render() {
    return (
      <App>
        <Window
          title="Proton Native Rocks!"
          size={{ w: 300, h: 300 }}
          menuBar={false}
          margined
        >
          <Box>
            <Area>
              <Area.Text x="10" y="30" style={{ color: 'red' }}>
                <Area.Text style={{ fontSize: 20 }}>
                  Hi!
                </Area.Text>
                {'\n'}
                Test{'\n'}
                <Area.Text style={{ color: 'black', fontFamily: 'Arial' }}>
                  Sans serif
                </Area.Text>
              </Area.Text>
            </Area>
          </Box>
        </Window>
      </App>
    );
  }
}
<!-- gh-comment-id:390472997 --> @mischnic commented on GitHub (May 20, 2018): Proof of concept at https://github.com/mischnic/proton-native/tree/font: ![bildschirmfoto 2018-05-20 um 14 00 30](https://user-images.githubusercontent.com/4586894/40278695-484ccc54-5c36-11e8-930f-f975b8331a91.png) ```jsx class Example extends Component { render() { return ( <App> <Window title="Proton Native Rocks!" size={{ w: 300, h: 300 }} menuBar={false} margined > <Box> <Area> <Area.Text x="10" y="30" style={{ color: 'red' }}> <Area.Text style={{ fontSize: 20 }}> Hi! </Area.Text> {'\n'} Test{'\n'} <Area.Text style={{ color: 'black', fontFamily: 'Arial' }}> Sans serif </Area.Text> </Area.Text> </Area> </Box> </Window> </App> ); } } ```
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/proton-native#84
No description provided.