2015-03-26 08:43:17 +00:00
|
|
|
/**
|
2018-09-11 22:27:47 +00:00
|
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
2016-07-12 12:51:57 +00:00
|
|
|
*
|
2018-02-17 02:24:55 +00:00
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
2016-07-12 12:51:57 +00:00
|
|
|
*
|
2018-05-11 20:32:37 +00:00
|
|
|
* @format
|
2015-03-26 08:43:17 +00:00
|
|
|
*/
|
2018-05-11 20:32:37 +00:00
|
|
|
|
2015-03-26 08:43:17 +00:00
|
|
|
'use strict';
|
|
|
|
|
2016-04-24 14:12:41 +00:00
|
|
|
var React = require('react');
|
2016-04-09 03:36:40 +00:00
|
|
|
var ReactNative = require('react-native');
|
2018-05-11 20:32:37 +00:00
|
|
|
var {StyleSheet, View} = ReactNative;
|
2015-03-26 08:43:17 +00:00
|
|
|
|
|
|
|
var styles = StyleSheet.create({
|
|
|
|
box: {
|
|
|
|
width: 100,
|
|
|
|
height: 100,
|
|
|
|
},
|
|
|
|
border1: {
|
|
|
|
borderWidth: 10,
|
2015-09-17 15:36:08 +00:00
|
|
|
borderColor: 'brown',
|
2015-03-26 08:43:17 +00:00
|
|
|
},
|
|
|
|
borderRadius: {
|
|
|
|
borderWidth: 10,
|
|
|
|
borderRadius: 10,
|
2015-09-17 15:36:08 +00:00
|
|
|
borderColor: 'cyan',
|
2015-03-26 08:43:17 +00:00
|
|
|
},
|
|
|
|
border2: {
|
|
|
|
borderWidth: 10,
|
|
|
|
borderTopColor: 'red',
|
|
|
|
borderRightColor: 'yellow',
|
|
|
|
borderBottomColor: 'green',
|
|
|
|
borderLeftColor: 'blue',
|
|
|
|
},
|
|
|
|
border3: {
|
|
|
|
borderColor: 'purple',
|
|
|
|
borderTopWidth: 10,
|
|
|
|
borderRightWidth: 20,
|
|
|
|
borderBottomWidth: 30,
|
|
|
|
borderLeftWidth: 40,
|
|
|
|
},
|
|
|
|
border4: {
|
|
|
|
borderTopWidth: 10,
|
|
|
|
borderTopColor: 'red',
|
|
|
|
borderRightWidth: 20,
|
|
|
|
borderRightColor: 'yellow',
|
|
|
|
borderBottomWidth: 30,
|
|
|
|
borderBottomColor: 'green',
|
|
|
|
borderLeftWidth: 40,
|
|
|
|
borderLeftColor: 'blue',
|
|
|
|
},
|
2015-04-27 10:50:07 +00:00
|
|
|
border5: {
|
|
|
|
borderRadius: 50,
|
|
|
|
borderTopWidth: 10,
|
|
|
|
borderTopColor: 'red',
|
|
|
|
borderRightWidth: 20,
|
|
|
|
borderRightColor: 'yellow',
|
|
|
|
borderBottomWidth: 30,
|
|
|
|
borderBottomColor: 'green',
|
|
|
|
borderLeftWidth: 40,
|
|
|
|
borderLeftColor: 'blue',
|
|
|
|
},
|
2015-05-13 15:22:21 +00:00
|
|
|
border6: {
|
|
|
|
borderTopWidth: 10,
|
|
|
|
borderTopColor: 'red',
|
|
|
|
borderRightWidth: 20,
|
|
|
|
borderRightColor: 'yellow',
|
|
|
|
borderBottomWidth: 30,
|
|
|
|
borderBottomColor: 'green',
|
|
|
|
borderLeftWidth: 40,
|
|
|
|
borderLeftColor: 'blue',
|
|
|
|
|
|
|
|
borderTopLeftRadius: 100,
|
|
|
|
},
|
2015-05-26 09:12:28 +00:00
|
|
|
border7: {
|
2015-05-28 15:52:46 +00:00
|
|
|
borderWidth: 10,
|
2015-11-09 16:00:26 +00:00
|
|
|
borderColor: '#f007',
|
2015-05-28 15:52:46 +00:00
|
|
|
borderRadius: 30,
|
|
|
|
overflow: 'hidden',
|
2015-05-26 09:12:28 +00:00
|
|
|
},
|
|
|
|
border7_inner: {
|
|
|
|
backgroundColor: 'blue',
|
2015-05-28 15:52:46 +00:00
|
|
|
width: 100,
|
2018-05-11 20:32:37 +00:00
|
|
|
height: 100,
|
2015-05-26 09:12:28 +00:00
|
|
|
},
|
2015-11-06 12:50:12 +00:00
|
|
|
border8: {
|
|
|
|
width: 60,
|
|
|
|
height: 60,
|
|
|
|
borderColor: 'black',
|
|
|
|
marginRight: 10,
|
|
|
|
backgroundColor: 'lightgrey',
|
|
|
|
},
|
2016-02-08 18:42:31 +00:00
|
|
|
border9: {
|
|
|
|
borderWidth: 10,
|
|
|
|
borderTopLeftRadius: 10,
|
|
|
|
borderBottomRightRadius: 20,
|
|
|
|
borderColor: 'black',
|
|
|
|
},
|
|
|
|
border10: {
|
|
|
|
borderWidth: 10,
|
|
|
|
backgroundColor: 'white',
|
|
|
|
borderTopLeftRadius: 10,
|
|
|
|
borderBottomRightRadius: 20,
|
|
|
|
borderColor: 'black',
|
2016-02-19 10:58:27 +00:00
|
|
|
elevation: 10,
|
|
|
|
},
|
|
|
|
border11: {
|
|
|
|
width: 0,
|
|
|
|
height: 0,
|
|
|
|
borderStyle: 'solid',
|
|
|
|
overflow: 'hidden',
|
|
|
|
borderTopWidth: 50,
|
|
|
|
borderRightWidth: 0,
|
|
|
|
borderBottomWidth: 50,
|
|
|
|
borderLeftWidth: 100,
|
|
|
|
borderTopColor: 'transparent',
|
|
|
|
borderRightColor: 'transparent',
|
|
|
|
borderBottomColor: 'transparent',
|
|
|
|
borderLeftColor: 'red',
|
|
|
|
},
|
2017-10-19 02:29:33 +00:00
|
|
|
border12: {
|
|
|
|
borderStyle: 'solid',
|
|
|
|
overflow: 'hidden',
|
|
|
|
borderTopWidth: 10,
|
|
|
|
borderRightWidth: 20,
|
|
|
|
borderBottomWidth: 30,
|
|
|
|
borderLeftWidth: 40,
|
|
|
|
borderRadius: 20,
|
|
|
|
},
|
|
|
|
border13: {
|
|
|
|
borderStyle: 'solid',
|
|
|
|
overflow: 'hidden',
|
|
|
|
borderTopWidth: 10,
|
|
|
|
borderRightWidth: 20,
|
|
|
|
borderBottomWidth: 30,
|
|
|
|
borderLeftWidth: 40,
|
|
|
|
borderTopColor: 'red',
|
|
|
|
borderRightColor: 'green',
|
|
|
|
borderBottomColor: 'blue',
|
|
|
|
borderLeftColor: 'magenta',
|
|
|
|
borderRadius: 20,
|
|
|
|
},
|
|
|
|
border14: {
|
|
|
|
borderStyle: 'solid',
|
|
|
|
overflow: 'hidden',
|
|
|
|
borderTopWidth: 10,
|
|
|
|
borderRightWidth: 20,
|
|
|
|
borderBottomWidth: 30,
|
|
|
|
borderLeftWidth: 40,
|
|
|
|
borderTopColor: 'red',
|
|
|
|
borderRightColor: 'green',
|
|
|
|
borderBottomColor: 'blue',
|
|
|
|
borderLeftColor: 'magenta',
|
|
|
|
borderTopLeftRadius: 10,
|
|
|
|
borderTopRightRadius: 40,
|
|
|
|
borderBottomRightRadius: 30,
|
|
|
|
borderBottomLeftRadius: 40,
|
2018-05-11 20:32:37 +00:00
|
|
|
},
|
2015-03-26 08:43:17 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
exports.title = 'Border';
|
2018-05-11 20:32:37 +00:00
|
|
|
exports.description =
|
|
|
|
'Demonstrates some of the border styles available to Views.';
|
2015-03-26 08:43:17 +00:00
|
|
|
exports.examples = [
|
|
|
|
{
|
|
|
|
title: 'Equal-Width / Same-Color',
|
|
|
|
description: 'borderWidth & borderColor',
|
|
|
|
render() {
|
|
|
|
return <View style={[styles.box, styles.border1]} />;
|
2018-05-11 20:32:37 +00:00
|
|
|
},
|
2015-03-26 08:43:17 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Equal-Width / Same-Color',
|
2015-04-27 10:50:07 +00:00
|
|
|
description: 'borderWidth & borderColor & borderRadius',
|
2015-03-26 08:43:17 +00:00
|
|
|
render() {
|
|
|
|
return <View style={[styles.box, styles.borderRadius]} />;
|
2018-05-11 20:32:37 +00:00
|
|
|
},
|
2015-03-26 08:43:17 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Equal-Width Borders',
|
|
|
|
description: 'borderWidth & border*Color',
|
|
|
|
render() {
|
|
|
|
return <View style={[styles.box, styles.border2]} />;
|
2018-05-11 20:32:37 +00:00
|
|
|
},
|
2015-03-26 08:43:17 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Same-Color Borders',
|
|
|
|
description: 'border*Width & borderColor',
|
|
|
|
render() {
|
|
|
|
return <View style={[styles.box, styles.border3]} />;
|
2018-05-11 20:32:37 +00:00
|
|
|
},
|
2015-03-26 08:43:17 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Custom Borders',
|
|
|
|
description: 'border*Width & border*Color',
|
|
|
|
render() {
|
|
|
|
return <View style={[styles.box, styles.border4]} />;
|
2018-05-11 20:32:37 +00:00
|
|
|
},
|
2015-03-26 08:43:17 +00:00
|
|
|
},
|
2015-04-27 10:50:07 +00:00
|
|
|
{
|
|
|
|
title: 'Custom Borders',
|
|
|
|
description: 'border*Width & border*Color',
|
2015-09-01 17:46:28 +00:00
|
|
|
platform: 'ios',
|
2015-04-27 10:50:07 +00:00
|
|
|
render() {
|
|
|
|
return <View style={[styles.box, styles.border5]} />;
|
2018-05-11 20:32:37 +00:00
|
|
|
},
|
2015-04-27 10:50:07 +00:00
|
|
|
},
|
2015-05-13 15:22:21 +00:00
|
|
|
{
|
|
|
|
title: 'Custom Borders',
|
|
|
|
description: 'border*Width & border*Color',
|
2015-09-01 17:46:28 +00:00
|
|
|
platform: 'ios',
|
2015-05-13 15:22:21 +00:00
|
|
|
render() {
|
|
|
|
return <View style={[styles.box, styles.border6]} />;
|
2018-05-11 20:32:37 +00:00
|
|
|
},
|
2015-05-13 15:22:21 +00:00
|
|
|
},
|
2015-05-26 09:12:28 +00:00
|
|
|
{
|
|
|
|
title: 'Custom Borders',
|
|
|
|
description: 'borderRadius & clipping',
|
2015-09-01 17:46:28 +00:00
|
|
|
platform: 'ios',
|
2015-05-26 09:12:28 +00:00
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<View style={[styles.box, styles.border7]}>
|
|
|
|
<View style={styles.border7_inner} />
|
|
|
|
</View>
|
|
|
|
);
|
2018-05-11 20:32:37 +00:00
|
|
|
},
|
2015-05-26 09:12:28 +00:00
|
|
|
},
|
2015-11-06 12:50:12 +00:00
|
|
|
{
|
|
|
|
title: 'Single Borders',
|
|
|
|
description: 'top, left, bottom right',
|
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<View style={{flexDirection: 'row'}}>
|
|
|
|
<View style={[styles.box, styles.border8, {borderTopWidth: 5}]} />
|
|
|
|
<View style={[styles.box, styles.border8, {borderLeftWidth: 5}]} />
|
|
|
|
<View style={[styles.box, styles.border8, {borderBottomWidth: 5}]} />
|
|
|
|
<View style={[styles.box, styles.border8, {borderRightWidth: 5}]} />
|
|
|
|
</View>
|
|
|
|
);
|
2018-05-11 20:32:37 +00:00
|
|
|
},
|
2015-11-06 12:50:12 +00:00
|
|
|
},
|
2016-02-08 18:42:31 +00:00
|
|
|
{
|
|
|
|
title: 'Corner Radii',
|
|
|
|
description: 'borderTopLeftRadius & borderBottomRightRadius',
|
|
|
|
render() {
|
|
|
|
return <View style={[styles.box, styles.border9]} />;
|
2018-05-11 20:32:37 +00:00
|
|
|
},
|
2016-02-08 18:42:31 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Corner Radii / Elevation',
|
|
|
|
description: 'borderTopLeftRadius & borderBottomRightRadius & elevation',
|
|
|
|
platform: 'android',
|
|
|
|
render() {
|
|
|
|
return <View style={[styles.box, styles.border10]} />;
|
2018-05-11 20:32:37 +00:00
|
|
|
},
|
2016-02-08 18:42:31 +00:00
|
|
|
},
|
2016-02-19 10:58:27 +00:00
|
|
|
{
|
|
|
|
title: 'CSS Trick - Triangle',
|
|
|
|
description: 'create a triangle by manipulating border colors and widths',
|
|
|
|
render() {
|
|
|
|
return <View style={[styles.border11]} />;
|
2018-05-11 20:32:37 +00:00
|
|
|
},
|
2016-02-19 10:58:27 +00:00
|
|
|
},
|
2017-10-19 02:29:33 +00:00
|
|
|
{
|
|
|
|
title: 'Curved border(Left|Right|Bottom|Top)Width',
|
|
|
|
description: 'Make a non-uniform width curved border',
|
|
|
|
render() {
|
|
|
|
return <View style={[styles.box, styles.border12]} />;
|
2018-05-11 20:32:37 +00:00
|
|
|
},
|
2017-10-19 02:29:33 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Curved border(Left|Right|Bottom|Top)Color',
|
|
|
|
description: 'Make a non-uniform color curved border',
|
|
|
|
render() {
|
|
|
|
return <View style={[styles.box, styles.border13]} />;
|
2018-05-11 20:32:37 +00:00
|
|
|
},
|
2017-10-19 02:29:33 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Curved border(Top|Bottom)(Left|Right)Radius',
|
|
|
|
description: 'Make a non-uniform radius curved border',
|
|
|
|
render() {
|
|
|
|
return <View style={[styles.box, styles.border14]} />;
|
2018-05-11 20:32:37 +00:00
|
|
|
},
|
|
|
|
},
|
2015-03-26 08:43:17 +00:00
|
|
|
];
|