formaat-design / reshaped

Community repository for storing examples, reporting issues and tracking roadmap
https://reshaped.so
110 stars 3 forks source link

[Feature] Copy Text to Clipboard #150

Closed mmailaender closed 1 year ago

mmailaender commented 1 year ago

https://codyhouse.co/ds/components/info/copy-to-clipboard

Could be maybe an opiniated component from <Text> or <Input>

blvdmitry commented 1 year ago

I think there might be a bunch of various options of how developers/designers would need to handle this and it's quite easy to combine multiple components to achieve this. For example, you can do the following where you only need access to the string you want to copy.

<View insetTop={2} insetRight={2} position="absolute">
  <Button onClick={() => navigator.clipboard.writeText(codeSnippet)}>Copy</Button>
</View>

I think it made a lot of sense to have this as a component in the past when you needed to emit custom events to make it work but now it takes just one line of javascript